Skip to content

Commit aa8d773

Browse files
committed
integrate docker in gh action
1 parent c4dea43 commit aa8d773

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/build-and-release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
permissions:
1313
contents: write
1414

15+
env:
16+
# Use docker.io for Docker Hub if empty
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: ${{ github.repository }}
19+
1520
jobs:
1621
test:
1722
runs-on: ubuntu-latest
@@ -49,6 +54,62 @@ jobs:
4954
env:
5055
ONNXRUNTIME_LIB_PATH: /usr/local/lib/libonnxruntime.so
5156

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+
52113
goreleaser:
53114
runs-on: ubuntu-latest
54115
needs: test

0 commit comments

Comments
 (0)