Merge pull request #13 from allthingslinux/fix/labeler-yaml-keys #4
Workflow file for this run
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: Reusable — Docker Build & Push | ||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| GITHUB_TOKEN: | ||
|
Check failure on line 6 in .github/workflows/reusable-docker-build.yml
|
||
| description: Token for GHCR login (pass secrets.GITHUB_TOKEN from the caller) | ||
| required: true | ||
| inputs: | ||
| context: | ||
| required: true | ||
| type: string | ||
| image-name: | ||
| required: true | ||
| type: string | ||
| push: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| platforms: | ||
| required: false | ||
| type: string | ||
| default: "linux/amd64" | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| id-token: write | ||
| attestations: write | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| - name: Setup Buildx | ||
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3 | ||
| - name: Log in to GHCR | ||
| uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3 | ||
| if: inputs.push | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Extract metadata | ||
| id: meta | ||
| uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5 | ||
| with: | ||
| images: ${{ inputs.image-name }} | ||
| tags: | | ||
| type=sha,format=short | ||
| type=ref,event=branch | ||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||
| - name: Build and push | ||
| uses: docker/build-push-action@14487ce63c7a62a4a324b0bfb37086795e31c6c1 # v6 | ||
| id: build | ||
| with: | ||
| context: ${{ inputs.context }} | ||
| file: ${{ inputs.context }}/Containerfile | ||
| push: ${{ inputs.push }} | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| platforms: ${{ inputs.platforms }} | ||
| cache-from: type=gha,scope=${{ inputs.image-name }} | ||
| cache-to: type=gha,mode=max,scope=${{ inputs.image-name }} | ||
| provenance: true | ||
| sbom: true | ||
| - name: Attest build provenance | ||
| uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0 | ||
| if: inputs.push | ||
| with: | ||
| subject-name: ${{ inputs.image-name }} | ||
| subject-digest: ${{ steps.build.outputs.digest }} | ||
| push-to-registry: true | ||