Skip to content

Commit 163e25a

Browse files
authored
Merge pull request #203 from refactor-group/remove_arm64_builds
Remove arm64 builds since we don't need them currently.
2 parents a9cac15 + f628ade commit 163e25a

File tree

8 files changed

+251
-158
lines changed

8 files changed

+251
-158
lines changed

.dockerignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Build outputs and caches
2+
.next/
3+
coverage/
4+
dist/
5+
build/
6+
7+
# Dependencies
8+
node_modules/
9+
10+
# Environment and config
11+
.env*
12+
.env.local
13+
.env.development.local
14+
.env.test.local
15+
.env.production.local
16+
17+
# Logs
18+
*.log
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
lerna-debug.log*
23+
24+
# Development and testing
25+
.eslintcache
26+
.nyc_output
27+
playwright-report/
28+
test-results/
29+
30+
# Version control and CI
31+
.git/
32+
.github/
33+
.gitignore
34+
35+
# IDE and editor files
36+
.vscode/
37+
.idea/
38+
*.swp
39+
*.swo
40+
*~
41+
42+
# OS generated files
43+
.DS_Store
44+
.DS_Store?
45+
._*
46+
.Spotlight-V100
47+
.Trashes
48+
ehthumbs.db
49+
Thumbs.db
50+
51+
# Documentation
52+
README.md
53+
CHANGELOG.md
54+
docs/
55+
56+
# Temporary files
57+
*.tmp
58+
*.temp
59+
tmp/
60+
temp/
Lines changed: 115 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Non-Production Images
1+
name: Build, Test & Push to GHCR
22

33
on:
44
push:
@@ -8,102 +8,134 @@ on:
88
types: [opened, synchronize, reopened]
99
workflow_dispatch:
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
permissions:
16+
contents: read
17+
1118
env:
1219
REGISTRY: ghcr.io
1320
ORG_NAME: refactor-group
1421
REPO_NAME: refactor-platform-fe
22+
NODE_ENV: test
1523

1624
jobs:
17-
build_and_push_amd64:
25+
# === LINT JOB ===
26+
lint:
27+
name: Lint & Format Check
1828
runs-on: ubuntu-24.04
1929

20-
permissions:
21-
contents: read
22-
packages: write
23-
id-token: write
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v5
36+
with:
37+
node-version: 24.x
38+
cache: 'npm'
39+
cache-dependency-path: package-lock.json
40+
41+
- name: Install dependencies
42+
run: npm ci --prefer-offline
43+
44+
- name: Run ESLint
45+
run: npm run lint
46+
47+
# === TEST JOB ===
48+
test:
49+
name: Build & Test
50+
runs-on: ubuntu-24.04
2451

2552
steps:
26-
- uses: actions/checkout@v4
53+
- name: Checkout
54+
uses: actions/checkout@v4
2755

28-
- uses: docker/setup-buildx-action@v3
56+
- name: Setup Node.js
57+
uses: actions/setup-node@v5
2958
with:
30-
install: true
59+
node-version: 24.x
60+
cache: 'npm'
61+
cache-dependency-path: package-lock.json
3162

32-
- name: Docker login
33-
uses: docker/login-action@v2
63+
# 🎯 Next.js build cache (job-specific to prevent race conditions)
64+
- name: Cache Next.js build
65+
uses: actions/cache@v4
3466
with:
35-
registry: ${{ env.REGISTRY }}
36-
username: ${{ github.actor }}
37-
password: ${{ secrets.GITHUB_TOKEN }}
67+
path: .next/cache
68+
key: ${{ runner.os }}-nextjs-test-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
69+
restore-keys: |
70+
${{ runner.os }}-nextjs-test-${{ hashFiles('**/package-lock.json') }}-
71+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
72+
73+
# 🎯 Playwright browser cache
74+
- name: Cache Playwright browsers
75+
uses: actions/cache@v4
76+
with:
77+
path: ~/.cache/ms-playwright
78+
key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }}
79+
restore-keys: |
80+
${{ runner.os }}-playwright-
3881
39-
- name: Set Image Tag
40-
id: vars
41-
run: |
42-
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
43-
IMAGE_BASE="${{ env.REGISTRY }}/${{ env.ORG_NAME }}/${{ env.REPO_NAME }}/${BRANCH_NAME}"
44-
echo "tag=${IMAGE_BASE}:amd64" >> $GITHUB_OUTPUT
82+
- name: Install dependencies
83+
run: npm ci --prefer-offline
4584

46-
- name: Build + Push AMD64
47-
id: build
48-
uses: docker/build-push-action@v5
49-
with:
50-
context: .
51-
file: ./Dockerfile
52-
target: runner
53-
platforms: linux/amd64
54-
push: true
55-
provenance: true
56-
sbom: true
57-
build-args: |
58-
NEXT_PUBLIC_BACKEND_SERVICE_PROTOCOL=${{ vars.BACKEND_SERVICE_PROTOCOL }}
59-
NEXT_PUBLIC_BACKEND_SERVICE_HOST=${{ vars.BACKEND_SERVICE_HOST }}
60-
NEXT_PUBLIC_BACKEND_SERVICE_PORT=${{ vars.BACKEND_SERVICE_PORT }}
61-
NEXT_PUBLIC_BACKEND_SERVICE_API_PATH=${{ vars.BACKEND_SERVICE_API_PATH }}
62-
NEXT_PUBLIC_BACKEND_API_VERSION=${{ vars.BACKEND_API_VERSION }}
63-
NEXT_PUBLIC_TIPTAP_APP_ID=${{ vars.TIPTAP_APP_ID }}
64-
FRONTEND_SERVICE_PORT=${{ vars.FRONTEND_SERVICE_PORT }}
65-
FRONTEND_SERVICE_INTERFACE=${{ vars.FRONTEND_SERVICE_INTERFACE }}
66-
tags: ${{ steps.vars.outputs.tag }}
67-
cache-from: type=gha,scope=amd64
68-
cache-to: type=gha,mode=max,scope=amd64
85+
- name: Build application
86+
run: npm run build
6987

70-
build_and_push_arm64:
71-
runs-on: ubuntu-24.04
88+
- name: Install Playwright browsers
89+
run: npx playwright install --with-deps
90+
91+
- name: Run unit tests
92+
run: npm run test:run
93+
94+
- name: Run E2E tests
95+
run: npm run test:e2e
7296

97+
# === DOCKER BUILD & PUSH JOB ===
98+
docker:
99+
name: Build & Push Docker Image
100+
runs-on: ubuntu-24.04
101+
needs: [lint, test] # Only run if lint and test pass
102+
if: github.event_name == 'push' || github.event_name == 'pull_request'
73103
permissions:
74104
contents: read
75105
packages: write
106+
attestations: write
76107
id-token: write
77108

78109
steps:
79-
- uses: actions/checkout@v4
110+
- name: Checkout
111+
uses: actions/checkout@v4
80112

81-
- uses: docker/setup-buildx-action@v3
82-
with:
83-
install: true
113+
- name: Set up Docker Buildx
114+
uses: docker/setup-buildx-action@v3
84115

85116
- name: Docker login
86-
uses: docker/login-action@v2
117+
uses: docker/login-action@v3
87118
with:
88119
registry: ${{ env.REGISTRY }}
89120
username: ${{ github.actor }}
90121
password: ${{ secrets.GITHUB_TOKEN }}
91122

92-
- name: Set Image Tag
93-
id: vars
123+
- name: Determine Image Tags
124+
id: tags
94125
run: |
95126
BRANCH_NAME=${GITHUB_HEAD_REF:-${GITHUB_REF##*/}}
96127
IMAGE_BASE="${{ env.REGISTRY }}/${{ env.ORG_NAME }}/${{ env.REPO_NAME }}/${BRANCH_NAME}"
97-
echo "tag=${IMAGE_BASE}:arm64" >> $GITHUB_OUTPUT
128+
echo "frontend_tags=$IMAGE_BASE:latest,$IMAGE_BASE:${{ github.sha }}" >> $GITHUB_OUTPUT
129+
echo "frontend_image_name=$IMAGE_BASE" >> $GITHUB_OUTPUT
98130
99-
- name: Build + Push ARM64
100-
id: build
131+
- name: Build and Push Frontend Image
132+
id: push_frontend
101133
uses: docker/build-push-action@v5
102134
with:
103135
context: .
104136
file: ./Dockerfile
105137
target: runner
106-
platforms: linux/arm64
138+
platforms: linux/amd64
107139
push: true
108140
provenance: true
109141
sbom: true
@@ -116,6 +148,30 @@ jobs:
116148
NEXT_PUBLIC_TIPTAP_APP_ID=${{ vars.TIPTAP_APP_ID }}
117149
FRONTEND_SERVICE_PORT=${{ vars.FRONTEND_SERVICE_PORT }}
118150
FRONTEND_SERVICE_INTERFACE=${{ vars.FRONTEND_SERVICE_INTERFACE }}
119-
tags: ${{ steps.vars.outputs.tag }}
120-
cache-from: type=gha,scope=arm64
121-
cache-to: type=gha,mode=max,scope=arm64
151+
tags: ${{ steps.tags.outputs.frontend_tags }}
152+
cache-from: type=gha,scope=frontend-nonprod
153+
cache-to: type=gha,mode=max,scope=frontend-nonprod
154+
labels: |
155+
org.opencontainers.image.title=Refactor Platform Frontend
156+
org.opencontainers.image.description=Next.js frontend for refactor coaching platform
157+
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
158+
org.opencontainers.image.revision=${{ github.sha }}
159+
160+
- name: Attest Frontend Build
161+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
162+
uses: actions/attest-build-provenance@v2
163+
with:
164+
subject-name: ${{ steps.tags.outputs.frontend_image_name }}
165+
subject-digest: ${{ steps.push_frontend.outputs.digest }}
166+
push-to-registry: true
167+
168+
- name: Print Usage Instructions
169+
run: |
170+
echo "🎉 Build, Test & Push completed successfully!"
171+
echo ""
172+
echo "📦 Frontend Image Pushed:"
173+
echo " docker pull ${{ steps.tags.outputs.frontend_image_name }}:latest"
174+
echo " docker pull ${{ steps.tags.outputs.frontend_image_name }}:${{ github.sha }}"
175+
echo ""
176+
echo "🚀 Run Frontend:"
177+
echo " docker run --rm --env-file .env -p 3000:3000 ${{ steps.tags.outputs.frontend_image_name }}:latest"

0 commit comments

Comments
 (0)