|
| 1 | +name: Release image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read # to fetch code (actions/checkout) |
| 10 | + |
| 11 | +env: |
| 12 | + REGISTRY_IMAGE: openproject/keycloak-openproject-id |
| 13 | + KEYCLOAK_VERSION: 26.3.3 |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + if: github.repository == 'opf/openproject-id' |
| 18 | + needs: |
| 19 | + - setup |
| 20 | + runs-on: |
| 21 | + labels: "runs-on=${{ github.run_id }}/ssh=false/${{ matrix.runner }}" |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + include: |
| 25 | + - platform: linux/amd64 |
| 26 | + digest: amd64 |
| 27 | + runner: runner=4cpu-linux-x64 |
| 28 | + - platform: linux/arm64/v8 |
| 29 | + digest: arm64 |
| 30 | + runner: runner=4cpu-linux-arm64 |
| 31 | + steps: |
| 32 | + - name: Checkout |
| 33 | + uses: actions/checkout@v5 |
| 34 | + - name: Set up QEMU |
| 35 | + uses: docker/setup-qemu-action@v3 |
| 36 | + - name: Set up Docker Buildx |
| 37 | + id: buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + - name: Login to Docker Hub |
| 40 | + uses: docker/login-action@v3 |
| 41 | + with: |
| 42 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 43 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 44 | + - name: Build image |
| 45 | + id: build |
| 46 | + uses: docker/build-push-action@v6 |
| 47 | + with: |
| 48 | + context: image |
| 49 | + file: image/Containerfile |
| 50 | + platforms: ${{ matrix.platform }} |
| 51 | + build-args: | |
| 52 | + BUILDKIT_PROGRESS=plain |
| 53 | + pull: true |
| 54 | + load: true |
| 55 | + tags: ${{ env.KEYCLOAK_VERSION }} |
| 56 | + cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} |
| 57 | + cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max |
| 58 | + - name: Push image |
| 59 | + id: push |
| 60 | + uses: docker/build-push-action@v6 |
| 61 | + with: |
| 62 | + context: image |
| 63 | + file: image/Containerfile |
| 64 | + platforms: ${{ matrix.platform }} |
| 65 | + build-args: | |
| 66 | + BUILDKIT_PROGRESS=plain |
| 67 | + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 68 | + cache-from: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }} |
| 69 | + cache-to: type=s3,blobs_prefix=cache/${{ github.repository }}/,manifests_prefix=cache/${{ github.repository }}/,region=${{ env.RUNS_ON_AWS_REGION }},bucket=${{ env.RUNS_ON_S3_BUCKET_CACHE }},mode=max |
| 70 | + merge: |
| 71 | + runs-on: ubuntu-latest |
| 72 | + needs: |
| 73 | + - setup |
| 74 | + - build |
| 75 | + steps: |
| 76 | + - name: Merge digests |
| 77 | + uses: actions/upload-artifact/merge@v4 |
| 78 | + with: |
| 79 | + pattern: "digests-${{ inputs.tag }}-${{ matrix.digest }}*" |
| 80 | + overwrite: true |
| 81 | + name: "merged-digests-${{ inputs.tag }}-${{ github.run_number }}-${{ github.run_attempt }}" |
| 82 | + - name: Download digests |
| 83 | + uses: actions/download-artifact@v5 |
| 84 | + with: |
| 85 | + name: "merged-digests-${{ inputs.tag }}-${{ github.run_number }}-${{ github.run_attempt }}" |
| 86 | + path: /tmp/digests |
| 87 | + - name: Set up Docker Buildx |
| 88 | + uses: docker/setup-buildx-action@v3 |
| 89 | + - name: Login to Docker Hub |
| 90 | + uses: docker/login-action@v3 |
| 91 | + with: |
| 92 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 93 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 94 | + - name: Create manifest list and push |
| 95 | + working-directory: /tmp/digests |
| 96 | + run: | |
| 97 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 98 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 99 | + - name: Inspect image |
| 100 | + run: | |
| 101 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.KEYCLOAK_VERSION }} |
0 commit comments