Files
springboot-cici-demo/.gitea/workflows/cicd.yaml
yangzelin 10fcba4f90
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 15s
refactor: 整理 Docker 资产并补充可复制 CI/CD 部署文档
2026-12-04 14:53:04 +08:00

32 lines
925 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 "$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 -f doc/devops/docker/Dockerfile -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"