feat: 创建 Spring Boot 4 项目及 Gitea/GitLab CI/CD 流水线
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
31
.gitea/workflows/cicd.yaml
Normal file
31
.gitea/workflows/cicd.yaml
Normal file
@@ -0,0 +1,31 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master, main]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
REGISTRY: registry.cn-hangzhou.aliyuncs.com
|
||||
IMAGE: registry.cn-hangzhou.aliyuncs.com/lightjob/springboot-cici-demo
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to registry
|
||||
run: echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${{ env.REGISTRY }}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
|
||||
|
||||
- name: Build image (Maven verify runs inside Dockerfile)
|
||||
run: |
|
||||
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
|
||||
docker build -t "$IMAGE:$SHORT_SHA" -t "$IMAGE:latest" .
|
||||
|
||||
- name: Push image
|
||||
run: |
|
||||
SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7)
|
||||
docker push "$IMAGE:$SHORT_SHA"
|
||||
docker push "$IMAGE:latest"
|
||||
Reference in New Issue
Block a user