Skip to content

Commit 1f6f755

Browse files
author
MuhammadTahaNasir
committed
chore: add generic frontend CI & deploy workflow for Vercel with folder check
1 parent 95ffdd0 commit 1f6f755

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

.github/workflows/ci-frontend.yml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,45 @@ jobs:
77
runs-on: ubuntu-latest
88
defaults:
99
run:
10-
# Default frontend folder, but users can change this in their repo
11-
working-directory: client
10+
working-directory: client # Default folder; users can change this
1211
steps:
1312
- uses: actions/checkout@v4
1413
- uses: actions/setup-node@v4
1514
with:
1615
node-version: 20
17-
- run: npm install
18-
- run: npm run lint
19-
- run: npm run build
16+
17+
# Check if client folder exists
18+
- name: Check client folder existence
19+
id: check_client
20+
run: |
21+
if [ -d "./client" ]; then
22+
echo "folder_exists=true" >> $GITHUB_OUTPUT
23+
else
24+
echo "folder_exists=false" >> $GITHUB_OUTPUT
25+
fi
26+
27+
# Run install & build only if client folder exists
28+
- name: Install dependencies
29+
if: steps.check_client.outputs.folder_exists == 'true'
30+
run: npm install
31+
32+
- name: Run lint
33+
if: steps.check_client.outputs.folder_exists == 'true'
34+
run: npm run lint
35+
36+
- name: Run build
37+
if: steps.check_client.outputs.folder_exists == 'true'
38+
run: npm run build
2039

2140
deploy-vercel:
2241
runs-on: ubuntu-latest
2342
needs: build-frontend
43+
if: needs.build-frontend.outputs.folder_exists == 'true' # Deploy only if build ran
2444
steps:
45+
- uses: actions/checkout@v4
2546
- uses: amondnet/vercel-action@v25
2647
with:
27-
vercel-token: ${{ secrets.VERCEL_TOKEN }} # User must add this secret
28-
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # User must add this secret
29-
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # User must add this secret
30-
working-directory: ./client # Default dir, can be changed
48+
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Must add in repo secrets
49+
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} # Must add in repo secrets
50+
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} # Must add in repo secrets
51+
working-directory: ./client # Default, can be changed by user

0 commit comments

Comments
 (0)