|
| 1 | +name: Publish Docker images |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + image-tag: |
| 7 | + default: latest |
| 8 | + description: The tag of the image to build and push |
| 9 | + required: true |
| 10 | + |
| 11 | +jobs: |
| 12 | + create-image: |
| 13 | + name: Create Docker image |
| 14 | + runs-on: ubuntu-24.04 |
| 15 | + permissions: |
| 16 | + packages: write |
| 17 | + contents: read |
| 18 | + attestations: write |
| 19 | + id-token: write |
| 20 | + strategy: |
| 21 | + matrix: |
| 22 | + image-name: |
| 23 | + - latex |
| 24 | + - latex-small |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Log in to GitHub Container Registry |
| 28 | + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # https://github.com/docker/login-action/releases/tag/v3.3.0 |
| 29 | + with: |
| 30 | + registry: ghcr.io |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + - name: Extract metadata (tags, labels) for Docker |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # https://github.com/docker/metadata-action/releases/tag/v5.7.0 |
| 36 | + with: |
| 37 | + images: ghcr.io/compwa/polarimetry-${{ matrix.image-name }} |
| 38 | + - name: Build and push Docker images |
| 39 | + id: push |
| 40 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # https://github.com/docker/build-push-action/releases/tag/v6.15.0 |
| 41 | + with: |
| 42 | + context: . |
| 43 | + file: .github/Dockerfile.${{ matrix.image-name }} |
| 44 | + labels: ${{ steps.meta.outputs.labels }} |
| 45 | + push: true |
| 46 | + tags: ${{ steps.meta.outputs.tags }} |
| 47 | + - name: Build Inventory Image |
| 48 | + run: | |
| 49 | + docker build -f .github/Dockerfile.${{ matrix.image-name }} . --tag ghcr.io/compwa/polarimetry-${{ matrix.image-name }}:${{ github.event.inputs.image-tag }} |
| 50 | + docker push ghcr.io/compwa/polarimetry-${{ matrix.image-name }}:${{ github.event.inputs.image-tag }} |
| 51 | + - name: Generate artifact attestation |
| 52 | + uses: actions/attest-build-provenance@v2 |
| 53 | + with: |
| 54 | + subject-name: ghcr.io/compwa/polarimetry-${{ matrix.image-name }} |
| 55 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 56 | + push-to-registry: true |
0 commit comments