Publish web image #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish web image | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: Existing tag to (re)build and publish, e.g. v0.13.0. Defaults to the triggering ref. | |
| required: false | |
| type: string | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| publish: | |
| name: Build & push web image to GHCR | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.tag || github.ref }} | |
| # Derive the image version from the tag (release ref or dispatch input) so | |
| # raw tags work for both triggers — semver-from-ref doesn't fire on dispatch. | |
| - id: ver | |
| shell: bash | |
| run: | | |
| REF="${{ github.event.inputs.tag || github.ref_name }}" | |
| V="${REF#v}" | |
| echo "version=$V" >> "$GITHUB_OUTPUT" | |
| echo "minor=${V%.*}" >> "$GITHUB_OUTPUT" | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - id: meta | |
| uses: docker/metadata-action@v5 | |
| # Annotate the INDEX (not just per-platform configs) so GHCR can read | |
| # org.opencontainers.image.source and auto-link the package to the repo. | |
| env: | |
| DOCKER_METADATA_ANNOTATIONS_LEVELS: index | |
| with: | |
| images: ghcr.io/${{ github.repository_owner }}/openconcho-web | |
| tags: | | |
| type=raw,value=${{ steps.ver.outputs.version }} | |
| type=raw,value=${{ steps.ver.outputs.minor }} | |
| type=raw,value=latest | |
| type=sha,format=short | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| # provenance off keeps the pushed artifact a plain multi-arch index, | |
| # so the index annotation below is what GHCR sees for repo linking. | |
| provenance: false | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| annotations: ${{ steps.meta.outputs.annotations }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |