Fix missing environment variable check in frontend-deploy.yml #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Frontend | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build: | |
defaults: | |
run: | |
working-directory: ./frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
id: cache | |
with: | |
path: ./frontend/node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: ${{ runner.os }}-node- | |
- name: Install dependencies if not found | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: npm install | |
- name: Check for build env # fail if not found | |
if: ${{ !vars.REACT_APP_API_URL || vars.REACT_APP_API_URL.length < 1}} | |
run: | | |
echo "Missing REACT_APP_API_URL environment variable" | |
exit 1 | |
env: | |
REACT_APP_API_URL: ${{ vars.REACT_APP_API_URL }} | |
- name: Build react to webpage | |
run: npm run build | |
env: | |
REACT_APP_API_URL: ${{ vars.REACT_APP_API_URL }} | |
- name: Upload built files as artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./frontend/build | |
deploy: | |
needs: build | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |