|
1 | 1 | name: Create and publish image |
2 | 2 | permissions: |
3 | | - contents: read # Needed to check out the repository |
| 3 | + contents: write # Needed to check out the repository and update releases |
4 | 4 | packages: write # Needed to push images to GitHub Container Registry (ghcr.io) |
| 5 | + attestations: write # For generating attestations |
| 6 | + id-token: write # For OIDC token authentication |
5 | 7 |
|
6 | 8 | on: |
7 | 9 | push: |
|
13 | 15 | build-and-push: |
14 | 16 | name: Build and push image |
15 | 17 | runs-on: ubuntu-latest |
16 | | - permissions: |
17 | | - contents: read |
18 | | - packages: write |
19 | | - attestations: write # For generating attestations |
20 | | - id-token: write # For OIDC token authentication |
21 | 18 | if: github.event_name != 'pull_request' |
22 | 19 | steps: |
23 | 20 | - name: Checkout |
|
38 | 35 | id: meta |
39 | 36 | uses: docker/metadata-action@v5 |
40 | 37 | with: |
41 | | - images: docker.io/${{ github.repository_owner }}/instance-manager,ghcr.io/${{ github.repository_owner }}/instance-manager |
| 38 | + images: docker.io/${{ github.repository_owner }}/${{ github.event.repository.name }},ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
42 | 39 | tags: | |
43 | 40 | type=semver,pattern={{version}} |
44 | 41 | type=semver,pattern={{major}}.{{minor}} |
@@ -83,13 +80,32 @@ jobs: |
83 | 80 | - name: Generate artifact attestation (dockerhub) |
84 | 81 | uses: actions/attest-build-provenance@v2 |
85 | 82 | with: |
86 | | - subject-name: docker.io/${{ github.repository_owner }}/instance-manager |
| 83 | + subject-name: docker.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
87 | 84 | subject-digest: ${{ steps.push.outputs.digest }} |
88 | 85 | push-to-registry: true |
89 | 86 |
|
90 | 87 | - name: Generate artifact attestation (ghcr) |
91 | 88 | uses: actions/attest-build-provenance@v2 |
92 | 89 | with: |
93 | | - subject-name: ghcr.io/${{ github.repository_owner }}/instance-manager |
| 90 | + subject-name: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }} |
94 | 91 | subject-digest: ${{ steps.push.outputs.digest }} |
95 | 92 | push-to-registry: true |
| 93 | + |
| 94 | + - name: Update GitHub Release with image and attestation links |
| 95 | + if: startsWith(github.ref, 'refs/tags/v') |
| 96 | + uses: softprops/action-gh-release@v2 |
| 97 | + with: |
| 98 | + tag_name: ${{ github.ref_name }} |
| 99 | + append_body: true |
| 100 | + body: | |
| 101 | + ## Docker Images |
| 102 | + - [DockerHub](https://hub.docker.com/r/${{ github.repository_owner }}/${{ github.event.repository.name }}/tags?name=${{ github.ref_name }}) |
| 103 | + - [GHCR](https://github.com/orgs/${{ github.repository_owner }}/packages/container/${{ github.event.repository.name }}) |
| 104 | + - `docker pull ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}` |
| 105 | + - `docker pull ${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}` |
| 106 | +
|
| 107 | + ## Attestations |
| 108 | + - DockerHub attestation for `${{ github.ref_name }}` published (see OCI provenance) |
| 109 | + - GHCR attestation for `${{ github.ref_name }}` published (see OCI provenance) |
| 110 | + env: |
| 111 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments