Publish verified Docker images to GHCR

Make deployments pull immutable CI-built images while keeping test failures diagnosable before any package is published.
This commit is contained in:
Rocky
2026-08-16 14:56:36 +08:00
parent 0af35d44f4
commit 41e2145334
7 changed files with 74 additions and 16 deletions
+43
View File
@@ -4,6 +4,7 @@ on:
pull_request:
push:
branches: [main]
tags: ["v*"]
permissions:
contents: read
@@ -41,7 +42,49 @@ jobs:
run: docker compose -f compose.yaml config --quiet
- name: Test
run: ./gradlew --no-daemon clean test
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ github.run_id }}
path: |
build/reports/tests/test
build/test-results/test
if-no-files-found: ignore
- name: Build deployable JAR
run: ./gradlew --no-daemon buildFatJar
- name: Build container
run: docker build -t osg-account-server:ci .
publish:
if: github.event_name == 'push'
needs: verify
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/${{ github.repository_owner }}/osg-account-server
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=sha-
- uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max