|
| 1 | +name: Docker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + # Publish semver tags as releases. |
| 7 | + tags: [ 'v*.*.*' ] |
| 8 | + pull_request: |
| 9 | + branches: [ "main" ] |
| 10 | + |
| 11 | +env: |
| 12 | + # Use docker.io for Docker Hub if empty |
| 13 | + REGISTRY: ghcr.io |
| 14 | + |
| 15 | +jobs: |
| 16 | + # Build job for manylinux_2_28 image |
| 17 | + build-manylinux: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + id-token: write |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + platform: |
| 27 | + - linux/amd64 |
| 28 | + - linux/arm64 |
| 29 | + steps: |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Inject slug/short variables |
| 34 | + uses: rlespinasse/[email protected] |
| 35 | + |
| 36 | + - name: Prepare |
| 37 | + run: | |
| 38 | + platform=${{ matrix.platform }} |
| 39 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 40 | +
|
| 41 | + # Install the cosign tool except on PR |
| 42 | + - name: Install cosign |
| 43 | + if: github.event_name != 'pull_request' |
| 44 | + uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 |
| 45 | + with: |
| 46 | + cosign-release: 'v2.1.1' |
| 47 | + |
| 48 | + # Set up QEMU for cross-platform builds |
| 49 | + - name: Set up QEMU |
| 50 | + uses: docker/setup-qemu-action@v3 |
| 51 | + |
| 52 | + # Set up BuildKit Docker container builder |
| 53 | + - name: Set up Docker Buildx |
| 54 | + uses: docker/setup-buildx-action@v3 |
| 55 | + |
| 56 | + # Login against a Docker registry except on PR |
| 57 | + - name: Log into registry ${{ env.REGISTRY }} |
| 58 | + if: github.event_name != 'pull_request' |
| 59 | + uses: docker/login-action@v3 |
| 60 | + with: |
| 61 | + registry: ${{ env.REGISTRY }} |
| 62 | + username: ${{ github.actor }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + |
| 65 | + - name: Determine Dockerfile for platform |
| 66 | + run: | |
| 67 | + if [ "${{ matrix.platform }}" = "linux/amd64" ]; then |
| 68 | + echo "DOCKERFILE=docker/Dockerfile.manylinux_2_28_X64" >> $GITHUB_ENV |
| 69 | + else |
| 70 | + echo "DOCKERFILE=docker/Dockerfile.manylinux_2_28_ARM64" >> $GITHUB_ENV |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: Build and push by digest |
| 74 | + id: build |
| 75 | + uses: docker/build-push-action@v6 |
| 76 | + with: |
| 77 | + provenance: false |
| 78 | + sbom: false |
| 79 | + file: ${{ env.DOCKERFILE }} |
| 80 | + platforms: ${{ matrix.platform }} |
| 81 | + tags: ghcr.io/insight-platform/manylinux_2_28 |
| 82 | + outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }} |
| 83 | + context: . |
| 84 | + cache-from: type=gha |
| 85 | + cache-to: type=gha,mode=max |
| 86 | + |
| 87 | + - name: Export digest |
| 88 | + run: | |
| 89 | + mkdir -p ${{ runner.temp }}/digests-manylinux |
| 90 | + digest="${{ steps.build.outputs.digest }}" |
| 91 | + touch "${{ runner.temp }}/digests-manylinux/${digest#sha256:}" |
| 92 | +
|
| 93 | + - name: Upload digest |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: digests-manylinux-${{ env.PLATFORM_PAIR }} |
| 97 | + path: ${{ runner.temp }}/digests-manylinux/* |
| 98 | + if-no-files-found: error |
| 99 | + retention-days: 1 |
| 100 | + |
| 101 | + |
| 102 | + # Merge job for manylinux_2_28 image |
| 103 | + merge-manylinux: |
| 104 | + runs-on: ubuntu-latest |
| 105 | + needs: |
| 106 | + - build-manylinux |
| 107 | + if: github.event_name != 'pull_request' |
| 108 | + permissions: |
| 109 | + contents: read |
| 110 | + packages: write |
| 111 | + steps: |
| 112 | + - name: Inject slug/short variables |
| 113 | + uses: rlespinasse/[email protected] |
| 114 | + |
| 115 | + - name: Download digests |
| 116 | + uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + path: ${{ runner.temp }}/digests-manylinux |
| 119 | + pattern: digests-manylinux-* |
| 120 | + merge-multiple: true |
| 121 | + |
| 122 | + - name: Set up Docker Buildx |
| 123 | + uses: docker/setup-buildx-action@v3 |
| 124 | + |
| 125 | + - name: Log into registry ${{ env.REGISTRY }} |
| 126 | + uses: docker/login-action@v3 |
| 127 | + with: |
| 128 | + registry: ${{ env.REGISTRY }} |
| 129 | + username: ${{ github.actor }} |
| 130 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + |
| 132 | + - name: Create manifest list and push |
| 133 | + working-directory: ${{ runner.temp }}/digests-manylinux |
| 134 | + run: | |
| 135 | + docker buildx imagetools create \ |
| 136 | + -t ghcr.io/insight-platform/manylinux_2_28:${{ env.GITHUB_REF_SLUG }} \ |
| 137 | + $(printf 'ghcr.io/insight-platform/manylinux_2_28@sha256:%s ' *) |
| 138 | +
|
| 139 | + - name: Inspect image |
| 140 | + run: | |
| 141 | + docker buildx imagetools inspect ghcr.io/insight-platform/manylinux_2_28:${{ env.GITHUB_REF_SLUG }} |
| 142 | +
|
0 commit comments