Skip to content

Commit b49affa

Browse files
committed
nextjs site build and push
1 parent e92899f commit b49affa

2 files changed

Lines changed: 43 additions & 50 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: build-nextjs-site.yaml
2+
on:
3+
4+
jobs:
Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,49 @@
11
name: Build and Push site
22

33
on:
4-
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
5-
4+
workflow_dispatch:
65

6+
# Define an environment variable for the image name to keep the workflow clean
77
env:
8-
QUAY_NAMESPACE: sshaaf
9-
IMAGE_NAME: waver-site
10-
QUAY_REPOSITORY: quay.io/sshaaf/waver-site
8+
IMAGE_NAME: quay.io/sshaaf/waver-site
119

1210
jobs:
1311
build-and-push:
14-
environment: build
1512
runs-on: ubuntu-latest
16-
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
with:
21-
path: waver-site
22-
23-
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v3
25-
26-
- name: Get Git SHA
27-
id: git-sha
28-
run: |
29-
echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
30-
echo "full-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
13+
permissions:
14+
contents: read
15+
packages: write
3116

32-
- name: Log in to Quay.io
33-
uses: docker/login-action@v3
34-
with:
35-
registry: quay.io
36-
username: ${{ secrets.QUAY_USERNAME }}
37-
password: ${{ secrets.QUAY_PASSWORD }}
38-
39-
- name: Build and push Docker image
40-
uses: docker/build-push-action@v5
41-
with:
42-
context: ./waver-site
43-
push: true
44-
tags: |
45-
${{ env.QUAY_REPOSITORY }}:${{ steps.git-sha.outputs.sha }}
46-
${{ env.QUAY_REPOSITORY }}:latest
47-
cache-from: type:gha
48-
cache-to: type:gha,mode=max
49-
platforms: linux/amd64,linux/arm64
50-
51-
- name: Output image info
52-
run: |
53-
echo "✅ Successfully built and pushed image:"
54-
echo " Repository: ${{ env.QUAY_REPOSITORY }}"
55-
echo " SHA Tag: ${{ steps.git-sha.outputs.sha }}"
56-
echo " Latest Tag: latest"
57-
echo " Full SHA: ${{ steps.git-sha.outputs.full-sha }}"
58-
echo " Image URLs:"
59-
echo " ${{ env.QUAY_REPOSITORY }}:${{ steps.git-sha.outputs.sha }}"
60-
echo " ${{ env.QUAY_REPOSITORY }}:latest"
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Log in to Quay.io
22+
uses: docker/login-action@v3
23+
with:
24+
registry: quay.io
25+
username: ${{ secrets.QUAY_USER }}
26+
password: ${{ secrets.QUAY_TOKEN }}
27+
28+
- name: Extract Docker metadata
29+
id: meta
30+
uses: docker/metadata-action@v5
31+
with:
32+
images: ${{ env.IMAGE_NAME }}
33+
# Creates tags like:
34+
# - type=sha,prefix=,format=short (e.g., a1b2c3d4)
35+
# - type=raw,value=latest,enable={{is_default_branch}} (e.g., latest for main branch)
36+
tags: |
37+
type=sha,format=short
38+
type=raw,value=latest,enable={{is_default_branch}}
39+
40+
- name: Build and push Docker image
41+
uses: docker/build-push-action@v5
42+
with:
43+
# The context is the subfolder containing the Dockerfile
44+
context: ./waver-site
45+
push: true
46+
tags: ${{ steps.meta.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels }}
48+
cache-from: type=gha
49+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)