ci(prod): update image build workflow to push to Forgejo registry with commit SHA
build-prod / build-push (push) Canceled after 0s

This commit is contained in:
Story Crater Bot
2026-08-21 20:44:16 -07:00
parent 8f0e97dacf
commit 58efc45bf4
+33 -17
View File
@@ -9,28 +9,44 @@ jobs:
runs-on: docker runs-on: docker
permissions: permissions:
packages: write packages: write
contents: read
env:
REGISTRY: forgejo.riotpiao.com
IMAGE_NAME: rock/kmsvc-manage
steps: steps:
- name: install buildx and git - name: Checkout code
run: apk add --no-cache docker git uses: actions/checkout@v4
- uses: actions/checkout@v4 - name: Get commit short SHA
id: short_sha
run: echo "sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Build and push image (commit SHA + latest) - name: Log in to Forgejo Container Registry
run: | uses: docker/login-action@v3
COMMIT_SHA=${{ github.sha }} with:
SHORT_SHA=${COMMIT_SHA:0:7} registry: ${{ env.REGISTRY }}
IMAGE_NAME="forgejo.riotpiao.com/rock/kmsvc-manage" username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
docker build \ - name: Extract metadata (tags, labels)
-t ${IMAGE_NAME}:${SHORT_SHA} \ id: meta
-t ${IMAGE_NAME}:latest \ uses: docker/metadata-action@v5
. with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.short_sha.outputs.sha }}
type=raw,value=latest,enable={{is_default_branch}}
# For now, tag locally. When registry auth is configured: - name: Build and push image
# docker push ${IMAGE_NAME}:${SHORT_SHA} uses: docker/build-push-action@v6
# docker push ${IMAGE_NAME}:latest with:
context: .
echo "Built image: ${IMAGE_NAME}:${SHORT_SHA} and ${IMAGE_NAME}:latest" platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max