|
1 | 1 | name: publish container image |
2 | 2 |
|
3 | | -# This workflow uses actions that are not certified by GitHub. |
4 | | -# They are provided by a third-party and are governed by |
5 | | -# separate terms of service, privacy policy, and support |
6 | | -# documentation. |
7 | | - |
8 | 3 | on: |
9 | 4 | push: |
10 | 5 | # Publish semver tags as releases. |
11 | 6 | tags: [ 'v*.*.*' ] |
12 | 7 |
|
13 | 8 | env: |
14 | | - # Use docker.io for Docker Hub if empty |
15 | 9 | REGISTRY: ghcr.io |
16 | 10 | # github.repository as <account>/<repo> |
17 | 11 | IMAGE_NAME: ${{ github.repository }} |
18 | 12 |
|
19 | 13 |
|
20 | 14 | jobs: |
21 | 15 | build: |
22 | | - |
23 | 16 | runs-on: ubuntu-latest |
24 | 17 | permissions: |
25 | 18 | contents: read |
26 | 19 | packages: write |
27 | | - # This is used to complete the identity challenge |
28 | | - # with sigstore/fulcio when running outside of PRs. |
29 | | - id-token: write |
30 | 20 |
|
31 | 21 | steps: |
32 | 22 | - name: Checkout repository |
33 | | - uses: actions/checkout@v3 |
34 | | - |
35 | | - # Install the cosign tool except on PR |
36 | | - # https://github.com/sigstore/cosign-installer |
37 | | - - name: Install cosign |
38 | | - if: github.event_name != 'pull_request' |
39 | | - uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 |
40 | | - with: |
41 | | - cosign-release: 'v2.1.1' |
42 | | - |
43 | | - # Setup QEMU for multi-arch builds |
44 | | - - name: Setup QEMU |
45 | | - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 |
46 | | - |
47 | | - # Workaround: https://github.com/docker/build-push-action/issues/461 |
48 | | - - name: Setup Docker buildx |
49 | | - uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf |
| 23 | + uses: actions/checkout@v4 |
50 | 24 |
|
51 | 25 | # Login against a Docker registry except on PR |
52 | 26 | # https://github.com/docker/login-action |
|
66 | 40 | with: |
67 | 41 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
68 | 42 |
|
69 | | - # Build and push Docker image with Buildx (don't push on PR) |
70 | | - # https://github.com/docker/build-push-action |
| 43 | + # platform = linux/amd64,linux/arm64,linux/s390x,linux/ppc64le |
71 | 44 | - name: Build and push Docker image |
72 | | - id: build-and-push |
73 | | - uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a |
74 | | - with: |
75 | | - context: . |
76 | | - platforms: linux/amd64,linux/arm,linux/arm64 |
77 | | - push: ${{ github.event_name != 'pull_request' }} |
78 | | - tags: ${{ steps.meta.outputs.tags }} |
79 | | - labels: ${{ steps.meta.outputs.labels }} |
80 | | - cache-from: type=gha |
81 | | - cache-to: type=gha,mode=max |
82 | | - |
83 | | - # Sign the resulting Docker image digest except on PRs. |
84 | | - # This will only write to the public Rekor transparency log when the Docker |
85 | | - # repository is public to avoid leaking data. If you would like to publish |
86 | | - # transparency data even for private images, pass --force to cosign below. |
87 | | - # https://github.com/sigstore/cosign |
88 | | - - name: Sign the published Docker image |
89 | | - if: ${{ github.event_name != 'pull_request' }} |
90 | | - env: |
91 | | - # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable |
92 | | - TAGS: ${{ steps.meta.outputs.tags }} |
93 | | - DIGEST: ${{ steps.build-and-push.outputs.digest }} |
94 | | - # This step uses the identity token to provision an ephemeral certificate |
95 | | - # against the sigstore community Fulcio instance. |
96 | | - run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
| 45 | + run: "make docker-buildx PLATFORMS=linux/amd64,linux/arm64,linux/s390x,linux/ppc64le IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}" |
0 commit comments