|
| 1 | +# SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +--- |
| 6 | +name: Docker • Build Deeploy GAP9 Container |
| 7 | + |
| 8 | +"on": |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + docker_image_deeploy: |
| 12 | + description: "Deeploy Image to use" |
| 13 | + required: false |
| 14 | + default: "ghcr.io/pulp-platform/deeploy:latest" |
| 15 | + |
| 16 | +jobs: |
| 17 | + prepare: |
| 18 | + name: Fetch branch name or tag |
| 19 | + runs-on: ubuntu-latest |
| 20 | + outputs: |
| 21 | + docker_tag: ${{ steps.generate_tag.outputs.docker_tag }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Set up environment variables |
| 26 | + run: | |
| 27 | + echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 28 | + echo "TAG_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV |
| 29 | + echo "IS_TAG=${GITHUB_REF_TYPE}" >> $GITHUB_ENV |
| 30 | +
|
| 31 | + - name: Set Docker tag |
| 32 | + id: generate_tag |
| 33 | + run: | |
| 34 | + if [[ "${{ env.IS_TAG }}" == "tag" ]]; then |
| 35 | + echo "docker_tag=${{ env.TAG_NAME }}" >> $GITHUB_OUTPUT |
| 36 | + else |
| 37 | + echo "docker_tag=${{ env.BRANCH_NAME }}" >> $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | +
|
| 40 | + build-deeploy-gap9: |
| 41 | + name: Build Deeploy GAP9 Image |
| 42 | + needs: [prepare] |
| 43 | + runs-on: ${{ matrix.runner }} |
| 44 | + outputs: |
| 45 | + digest-amd64: ${{ steps.digest.outputs.digest-amd64 }} |
| 46 | + digest-arm64: ${{ steps.digest.outputs.digest-arm64 }} |
| 47 | + strategy: |
| 48 | + fail-fast: false |
| 49 | + matrix: |
| 50 | + platform: [amd64, arm64] |
| 51 | + include: |
| 52 | + - platform: amd64 |
| 53 | + runner: ubuntu-latest |
| 54 | + - platform: arm64 |
| 55 | + runner: ubuntu-22.04-arm |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Free up disk space |
| 60 | + uses: jlumbroso/free-disk-space@v1.3.1 |
| 61 | + with: |
| 62 | + tool-cache: true |
| 63 | + android: true |
| 64 | + dotnet: true |
| 65 | + haskell: true |
| 66 | + large-packages: true |
| 67 | + |
| 68 | + - uses: docker/setup-buildx-action@v3 |
| 69 | + |
| 70 | + - name: GHCR Log-in |
| 71 | + uses: docker/login-action@v3 |
| 72 | + with: |
| 73 | + registry: ghcr.io |
| 74 | + username: ${{ github.actor }} |
| 75 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + - name: Build Cache for Docker |
| 78 | + id: cache |
| 79 | + uses: actions/cache@v4 |
| 80 | + with: |
| 81 | + path: var-ccache |
| 82 | + key: ${{ runner.os }}-${{ matrix.platform }}-build-cache-deeploy-gap9 |
| 83 | + |
| 84 | + - name: Inject build-cache |
| 85 | + uses: reproducible-containers/buildkit-cache-dance@v3.1.0 |
| 86 | + with: |
| 87 | + cache-map: | |
| 88 | + { |
| 89 | + "var-ccache": "/ccache" |
| 90 | + } |
| 91 | + skip-extraction: ${{ steps.cache.outputs.cache-hit }} |
| 92 | + |
| 93 | + - name: Lower Case Repository Name |
| 94 | + run: | |
| 95 | + echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} |
| 96 | + env: |
| 97 | + OWNER: "${{ github.repository_owner }}" |
| 98 | + |
| 99 | + - name: Load SSH key |
| 100 | + uses: webfactory/ssh-agent@v0.9.0 |
| 101 | + with: |
| 102 | + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 103 | + |
| 104 | + - name: Build and push final Deeploy image |
| 105 | + id: build |
| 106 | + uses: docker/build-push-action@v6 |
| 107 | + with: |
| 108 | + platforms: linux/${{ matrix.platform }} |
| 109 | + context: . |
| 110 | + cache-from: type=gha |
| 111 | + cache-to: type=gha,mode=min |
| 112 | + file: Container/Dockerfile.deeploy-gap9 |
| 113 | + push: true |
| 114 | + build-args: | |
| 115 | + DEEPLOY_IMAGE=${{ github.event.inputs.docker_image_deeploy }} |
| 116 | + ssh: default |
| 117 | + outputs: type=image,name=ghcr.io/${{ env.OWNER_LC }}/deeploy-gap9,annotation-index=true,name-canonical=true,push=true |
| 118 | + |
| 119 | + - name: Extract image digest |
| 120 | + id: digest |
| 121 | + run: echo "digest-${{ matrix.platform }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT |
| 122 | + |
| 123 | + merge-deeploy-gap9-images: |
| 124 | + name: Merge Deeploy GAP9 Images |
| 125 | + runs-on: ubuntu-latest |
| 126 | + needs: [prepare, build-deeploy-gap9] |
| 127 | + steps: |
| 128 | + - name: GHCR Log-in |
| 129 | + uses: docker/login-action@v3 |
| 130 | + with: |
| 131 | + registry: ghcr.io |
| 132 | + username: ${{ github.actor }} |
| 133 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 134 | + |
| 135 | + - name: Lower Case Repository Name |
| 136 | + run: | |
| 137 | + echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV} |
| 138 | + env: |
| 139 | + OWNER: "${{ github.repository_owner }}" |
| 140 | + |
| 141 | + - name: Merge Deeploy GAP9 Images |
| 142 | + uses: Noelware/docker-manifest-action@v1 |
| 143 | + with: |
| 144 | + inputs: | |
| 145 | + ghcr.io/${{ env.OWNER_LC }}/deeploy-gap9@${{ needs.build-deeploy-gap9.outputs.digest-amd64 }}, |
| 146 | + ghcr.io/${{ env.OWNER_LC }}/deeploy-gap9@${{ needs.build-deeploy-gap9.outputs.digest-arm64 }} |
| 147 | + tags: | |
| 148 | + ghcr.io/${{ env.OWNER_LC }}/deeploy-gap9:latest, |
| 149 | + ghcr.io/${{ env.OWNER_LC }}/deeploy-gap9:${{ needs.prepare.outputs.docker_tag }} |
| 150 | + push: true |
0 commit comments