|
| 1 | +name: Container image |
| 2 | + |
| 3 | +# Mirrors .gitea/workflows/container.yaml — publishes a multi-arch |
| 4 | +# (amd64 + arm64) image to the GitHub Container Registry whenever the |
| 5 | +# Gitea→GitHub mirror pushes a `v*` tag. Image lands at |
| 6 | +# ghcr.io/axodouble/quptime with tags :vX.Y.Z, :X.Y, and :latest. |
| 7 | +on: |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - 'v*' |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
| 16 | +jobs: |
| 17 | + image: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up QEMU |
| 24 | + uses: docker/setup-qemu-action@v3 |
| 25 | + |
| 26 | + - name: Set up Buildx |
| 27 | + uses: docker/setup-buildx-action@v3 |
| 28 | + |
| 29 | + # GHCR namespaces must be lowercase. Lowercase the repository |
| 30 | + # path once and reuse below so a mixed-case org/repo (e.g. |
| 31 | + # Axodouble/QUptime) still resolves to a valid image reference. |
| 32 | + - name: Resolve image name |
| 33 | + id: img |
| 34 | + run: | |
| 35 | + repo='${{ github.repository }}' |
| 36 | + echo "ref=ghcr.io/${repo,,}" >> "$GITHUB_OUTPUT" |
| 37 | +
|
| 38 | + - name: Compute version |
| 39 | + id: ver |
| 40 | + run: | |
| 41 | + echo "version=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT" |
| 42 | +
|
| 43 | + - name: Login to GHCR |
| 44 | + uses: docker/login-action@v3 |
| 45 | + with: |
| 46 | + registry: ghcr.io |
| 47 | + username: ${{ github.actor }} |
| 48 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + |
| 50 | + - name: Docker metadata |
| 51 | + id: meta |
| 52 | + uses: docker/metadata-action@v5 |
| 53 | + with: |
| 54 | + images: ${{ steps.img.outputs.ref }} |
| 55 | + tags: | |
| 56 | + type=semver,pattern={{version}} |
| 57 | + type=semver,pattern={{major}}.{{minor}} |
| 58 | + type=raw,value=latest |
| 59 | +
|
| 60 | + - name: Build and push |
| 61 | + uses: docker/build-push-action@v6 |
| 62 | + with: |
| 63 | + context: . |
| 64 | + file: ./docker/Dockerfile |
| 65 | + platforms: linux/amd64,linux/arm64 |
| 66 | + push: true |
| 67 | + tags: ${{ steps.meta.outputs.tags }} |
| 68 | + labels: ${{ steps.meta.outputs.labels }} |
| 69 | + build-args: | |
| 70 | + VERSION=${{ steps.ver.outputs.version }} |
| 71 | + cache-from: type=gha |
| 72 | + cache-to: type=gha,mode=max |
0 commit comments