Skip to content

Commit b4f12d7

Browse files
committed
Update the build & publish image workflow
1 parent 87c3c09 commit b4f12d7

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

.github/workflows/publish-image.yml

+31-14
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,49 @@ on:
55
branches:
66
- main
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
812
jobs:
913
build-and-publish:
1014
runs-on: ubuntu-latest
1115

16+
permissions:
17+
contents: read
18+
packages: write
19+
attestations: write
20+
id-token: write
21+
1222
steps:
1323
- name: Checkout code
1424
uses: actions/checkout@v4
1525

16-
# Add support for more platforms with QEMU (optional)
17-
# https://github.com/docker/setup-qemu-action
18-
# - name: Set up QEMU
19-
# uses: docker/setup-qemu-action@v3
20-
21-
- name: Set up Docker Buildx
22-
uses: docker/setup-buildx-action@v3
23-
24-
- name: Log in to GitHub Container Registry
25-
uses: docker/login-action@v3
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
2628
with:
27-
registry: ghcr.io
29+
registry: ${{ env.REGISTRY }}
2830
username: ${{ github.actor }}
29-
password: ${{ secrets.GH_PAT }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
3038

3139
- name: Build and push Docker image
32-
uses: docker/build-push-action@v6
40+
id: push
41+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
3342
with:
3443
context: .
3544
push: true
36-
tags: ghcr.io/${{ github.actor }}/qna-admin:latest
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
48+
- name: Generate artifact attestation
49+
uses: actions/attest-build-provenance@v1
50+
with:
51+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
52+
subject-digest: ${{ steps.push.outputs.digest }}
53+
push-to-registry: true

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN \
3838
FROM base AS runner
3939
WORKDIR /app
4040

41-
ENV NODE_ENV production
41+
ENV NODE_ENV=production
4242

4343
# Uncomment the following line in case you want to disable telemetry during runtime.
4444
# ENV NEXT_TELEMETRY_DISABLED 1
@@ -61,7 +61,7 @@ USER nextjs
6161

6262
EXPOSE 3000
6363

64-
ENV PORT 3000
64+
ENV PORT=3000
6565

6666
# server.js is created by next build from the standalone output
6767
# https://nextjs.org/docs/pages/api-reference/next-config-js/output

0 commit comments

Comments
 (0)