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