Skip to content

Commit a813f63

Browse files
committed
fix pushing server docker images to ghcr.io
1 parent 3dfd92a commit a813f63

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@ jobs:
1212
build-client-webpack:
1313
uses: ./.github/workflows/client-webpack.yml
1414

15-
build-server-image:
16-
uses: ./.github/workflows/server-image.yml
17-
1815
release:
19-
needs: [build-client-webpack, build-server-image]
16+
needs: build-client-webpack
2017
runs-on: ubuntu-latest
2118

2219
steps:

.github/workflows/server-image.yml

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ name: Build and push back-end server Docker image
33
on:
44
workflow_call:
55
workflow_dispatch:
6+
# Run automatically when a new tag is created
7+
push:
8+
tags:
9+
- 'v0.*' # alpha
10+
- 'v1.*' # release
611

712
env:
813
REGISTRY: ghcr.io
@@ -12,22 +17,53 @@ jobs:
1217
server-image:
1318
runs-on: ubuntu-latest
1419
permissions:
15-
contents: write
1620
packages: write
21+
contents: read
22+
attestations: write
23+
id-token: write
1724

1825
steps:
1926
- uses: actions/checkout@v4
2027

21-
- name: Log in to Container registry
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 'lts/*'
32+
33+
- name: Install Typescript
34+
run: npm install -g typescript
35+
working-directory: server
36+
37+
- name: Install dependencies
38+
run: npm install
39+
working-directory: server
40+
41+
- name: Log in to container registry
2242
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0
2343
with:
2444
registry: ${{ env.REGISTRY }}
2545
username: ${{ github.actor }}
2646
password: ${{ secrets.GITHUB_TOKEN }}
2747

28-
- name: Build and push Docker image
48+
- name: Extract metadata (tags, labels) for container image
49+
id: meta
50+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
51+
with:
52+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
53+
54+
- name: Build and push container image
55+
id: push
2956
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0
3057
with:
31-
context: "{{ defaultContext }}:server"
58+
file: ./server/Dockerfile
59+
context: ./server
3260
push: true
33-
tags: ${{ env.IMAGE_NAME }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
64+
- name: Generate artifact attestation
65+
uses: actions/attest-build-provenance@v2
66+
with:
67+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
68+
subject-digest: ${{ steps.push.outputs.digest }}
69+
push-to-registry: true

0 commit comments

Comments
 (0)