|
7 | 7 | runs-on: ubuntu-latest |
8 | 8 | defaults: |
9 | 9 | 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 |
12 | 11 | steps: |
13 | 12 | - uses: actions/checkout@v4 |
14 | 13 | - uses: actions/setup-node@v4 |
15 | 14 | with: |
16 | 15 | 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 |
20 | 39 |
|
21 | 40 | deploy-vercel: |
22 | 41 | runs-on: ubuntu-latest |
23 | 42 | needs: build-frontend |
| 43 | + if: needs.build-frontend.outputs.folder_exists == 'true' # Deploy only if build ran |
24 | 44 | steps: |
| 45 | + - uses: actions/checkout@v4 |
25 | 46 | - uses: amondnet/vercel-action@v25 |
26 | 47 | 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