Files
springboot-cici-demo/.gitea/workflows/cicd.yaml
yangzelin 5c7ee32d17
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
feat: 创建 Spring Boot 4 项目及 Gitea/GitLab CI/CD 流水线
2026-12-04 13:50:19 +08:00

32 lines
903 B
YAML

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"