Skip to content

Commit 5fa13a5

Browse files
authored
Merge pull request #116 from refactor-group/115-bug-build-and-push-non-production-fe-gh-actions-is-failing
Remove arm build and build cache to test cache corruption and multi…
2 parents 28e4b05 + 5f4418c commit 5fa13a5

File tree

1 file changed

+68
-50
lines changed

1 file changed

+68
-50
lines changed

.github/workflows/build_and_push_nonproduction_images.yml

Lines changed: 68 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,90 +10,108 @@ on:
1010

1111
env:
1212
REGISTRY: ghcr.io
13+
ORG_NAME: refactor-group
14+
REPO_NAME: refactor-platform-fe
1315

1416
jobs:
15-
build_and_push_frontend:
17+
build_and_push_amd64:
1618
runs-on: ubuntu-22.04
1719

1820
permissions:
1921
contents: read
2022
packages: write
21-
id-token: write # Required for Cosign OIDC signing
23+
id-token: write
2224

2325
steps:
24-
# Checkout the source code
2526
- uses: actions/checkout@v4
2627

27-
# Setup QEMU for emulating multi-arch (e.g., ARM64 on x86)
28-
- uses: docker/setup-qemu-action@v2
29-
with:
30-
platforms: linux/amd64,linux/arm64
31-
32-
# Setup Buildx for advanced Docker builds (multiarch, caching, sbom)
3328
- uses: docker/setup-buildx-action@v3
3429
with:
3530
install: true
3631

37-
# Login to GHCR (GitHub Container Registry)
3832
- name: Docker login
3933
uses: docker/login-action@v2
4034
with:
4135
registry: ${{ env.REGISTRY }}
4236
username: ${{ github.actor }}
4337
password: ${{ secrets.GITHUB_TOKEN }}
4438

45-
# Dynamically generate image tag and name based on repo/org/branch
46-
- name: Determine Image Tags
47-
id: tags
39+
- name: Set image tag
40+
id: vars
4841
run: |
4942
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
50-
ORG_NAME="refactor-group"
51-
REPO_NAME="refactor-platform-fe"
52-
IMAGE="${{ env.REGISTRY }}/${ORG_NAME}/${REPO_NAME}/${BRANCH_NAME}:latest"
53-
echo "tag=$IMAGE" >> $GITHUB_OUTPUT
54-
echo "image=$IMAGE" >> $GITHUB_OUTPUT
55-
56-
# Build, SBOM, and Push the multi-arch Docker image
57-
- name: Build + Push Frontend
43+
IMAGE_BASE="${{ env.REGISTRY }}/${{ env.ORG_NAME }}/${{ env.REPO_NAME }}/${BRANCH_NAME}"
44+
echo "tag=${IMAGE_BASE}:amd64" >> $GITHUB_OUTPUT
45+
46+
- name: Build + Push AMD64
47+
id: build
5848
uses: docker/build-push-action@v5
5949
with:
6050
context: .
61-
file: ./Dockerfile # Dockerfile is at the root of the repo
62-
target: runner # Your Dockerfile defines this stage
63-
platforms: linux/amd64,linux/arm64
51+
file: ./Dockerfile
52+
target: runner
53+
platforms: linux/amd64
6454
push: true
65-
provenance: true # Enables provenance metadata
66-
sbom: true # Enables SBOM generation
55+
provenance: true
56+
sbom: true
6757
build-args: |
6858
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL=${{ secrets.BACKEND_SERVICE_PROTOCOL }}
6959
NEXT_PUBLIC_BACKEND_SERVICE_HOST=${{ secrets.BACKEND_SERVICE_HOST }}
7060
NEXT_PUBLIC_BACKEND_SERVICE_PORT=${{ secrets.BACKEND_PORT }}
7161
NEXT_PUBLIC_BACKEND_API_VERSION=${{ secrets.BACKEND_API_VERSION }}
7262
FRONTEND_SERVICE_PORT=${{ secrets.FRONTEND_SERVICE_PORT }}
7363
FRONTEND_SERVICE_INTERFACE=${{ secrets.FRONTEND_SERVICE_INTERFACE }}
74-
tags: ${{ steps.tags.outputs.tag }}
75-
cache-from: type=gha # GitHub-hosted build cache
76-
cache-to: type=gha,mode=max
77-
78-
# Install Cosign CLI for image signing
79-
- name: Install Cosign
80-
uses: sigstore/cosign-installer@v3
81-
82-
# Sign image using GitHub OIDC token (no secrets needed)
83-
- name: Sign image with Cosign
84-
env:
85-
COSIGN_EXPERIMENTAL: "true"
86-
run: |
87-
cosign sign --yes ${{ steps.tags.outputs.image }}
64+
tags: ${{ steps.vars.outputs.tag }}
65+
cache-from: type=gha,scope=amd64
66+
cache-to: type=gha,mode=max,scope=amd64
67+
68+
build_and_push_arm64:
69+
runs-on: ubuntu-22.04
70+
71+
permissions:
72+
contents: read
73+
packages: write
74+
id-token: write
8875

89-
# Output usage instructions
90-
- name: Print Pull & Run Instructions
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- uses: docker/setup-buildx-action@v3
80+
with:
81+
install: true
82+
83+
- name: Docker login
84+
uses: docker/login-action@v2
85+
with:
86+
registry: ${{ env.REGISTRY }}
87+
username: ${{ github.actor }}
88+
password: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Set image tag
91+
id: vars
9192
run: |
92-
echo -e "\033[1;32mFrontend Image Pushed & Signed:\033[0m"
93-
echo " docker pull ${{ steps.tags.outputs.image }}"
94-
echo ""
95-
echo -e "\033[1;36mRun locally or with Compose:\033[0m"
96-
echo " docker run --rm --env-file .env -p 3000:3000 ${{ steps.tags.outputs.image }}"
97-
echo ""
98-
echo -e "\033[1;33mSignature Verification:\033[0m"
99-
echo " cosign verify ${{ steps.tags.outputs.image }}"
93+
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
94+
IMAGE_BASE="${{ env.REGISTRY }}/${{ env.ORG_NAME }}/${{ env.REPO_NAME }}/${BRANCH_NAME}"
95+
echo "tag=${IMAGE_BASE}:arm64" >> $GITHUB_OUTPUT
96+
97+
- name: Build + Push ARM64
98+
id: build
99+
uses: docker/build-push-action@v5
100+
with:
101+
context: .
102+
file: ./Dockerfile
103+
target: runner
104+
platforms: linux/arm64
105+
push: true
106+
provenance: true
107+
sbom: true
108+
build-args: |
109+
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL=${{ secrets.BACKEND_SERVICE_PROTOCOL }}
110+
NEXT_PUBLIC_BACKEND_SERVICE_HOST=${{ secrets.BACKEND_SERVICE_HOST }}
111+
NEXT_PUBLIC_BACKEND_SERVICE_PORT=${{ secrets.BACKEND_PORT }}
112+
NEXT_PUBLIC_BACKEND_API_VERSION=${{ secrets.BACKEND_API_VERSION }}
113+
FRONTEND_SERVICE_PORT=${{ secrets.FRONTEND_SERVICE_PORT }}
114+
FRONTEND_SERVICE_INTERFACE=${{ secrets.FRONTEND_SERVICE_INTERFACE }}
115+
tags: ${{ steps.vars.outputs.tag }}
116+
cache-from: type=gha,scope=arm64
117+
cache-to: type=gha,mode=max,scope=arm64

0 commit comments

Comments
 (0)