All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 15s
32 lines
925 B
YAML
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"
|