feat: 创建 Spring Boot 4 项目及 Gitea/GitLab CI/CD 流水线
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
yangzelin
2026-12-04 13:50:19 +08:00
commit 5c7ee32d17
16 changed files with 720 additions and 0 deletions

View 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"