|
12 | 12 | permissions: |
13 | 13 | contents: write |
14 | 14 |
|
| 15 | +env: |
| 16 | + # Use docker.io for Docker Hub if empty |
| 17 | + REGISTRY: ghcr.io |
| 18 | + IMAGE_NAME: ${{ github.repository }} |
| 19 | + |
15 | 20 | jobs: |
16 | 21 | test: |
17 | 22 | runs-on: ubuntu-latest |
|
49 | 54 | env: |
50 | 55 | ONNXRUNTIME_LIB_PATH: /usr/local/lib/libonnxruntime.so |
51 | 56 |
|
| 57 | + docker: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: test |
| 60 | + permissions: |
| 61 | + contents: read |
| 62 | + packages: write |
| 63 | + id-token: write |
| 64 | + steps: |
| 65 | + - |
| 66 | + name: Checkout |
| 67 | + uses: actions/checkout@v5 |
| 68 | + with: |
| 69 | + fetch-depth: 0 |
| 70 | + lfs: true |
| 71 | + - |
| 72 | + name: Install cosign |
| 73 | + if: github.event_name != 'pull_request' |
| 74 | + uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0 |
| 75 | + with: |
| 76 | + cosign-release: 'v2.2.4' |
| 77 | + - |
| 78 | + name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 |
| 80 | + - |
| 81 | + name: Log into registry ${{ env.REGISTRY }} |
| 82 | + if: github.event_name != 'pull_request' |
| 83 | + uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 |
| 84 | + with: |
| 85 | + registry: ${{ env.REGISTRY }} |
| 86 | + username: ${{ github.actor }} |
| 87 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 88 | + - |
| 89 | + name: Extract Docker metadata |
| 90 | + id: meta |
| 91 | + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 |
| 92 | + with: |
| 93 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 94 | + - |
| 95 | + name: Build and push Docker image |
| 96 | + id: build-and-push |
| 97 | + uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0 |
| 98 | + with: |
| 99 | + context: . |
| 100 | + push: ${{ github.event_name != 'pull_request' }} |
| 101 | + tags: ${{ steps.meta.outputs.tags }} |
| 102 | + labels: ${{ steps.meta.outputs.labels }} |
| 103 | + cache-from: type=gha |
| 104 | + cache-to: type=gha,mode=max |
| 105 | + - |
| 106 | + name: Sign the published Docker image |
| 107 | + if: ${{ github.event_name != 'pull_request' }} |
| 108 | + env: |
| 109 | + TAGS: ${{ steps.meta.outputs.tags }} |
| 110 | + DIGEST: ${{ steps.build-and-push.outputs.digest }} |
| 111 | + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}} |
| 112 | + |
52 | 113 | goreleaser: |
53 | 114 | runs-on: ubuntu-latest |
54 | 115 | needs: test |
|
0 commit comments