Skip to content

Frontend Build and upload to S3 #39

Frontend Build and upload to S3

Frontend Build and upload to S3 #39

name: Frontend Build and upload to S3
on:
release:
types: [released]
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
build_and_upload:
runs-on: ubuntu-latest
environment: Production
env:
CI: false
strategy:
matrix:
node-version: [20]
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache dependencies
uses: actions/cache@v4
id: npm-cache
with:
path: |
frontend/node_modules
~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('frontend/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install Node.js dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
working-directory: ./frontend
run: npm install
- name: Build frontend
working-directory: ./frontend
run: npm run build
env:
VITE_BASE_API_URL: ${{ vars.VITE_BASE_API_URL }}
VITE_MATOMO_ID: ${{ vars.VITE_MATOMO_ID }}
VITE_MATOMO_APP_DOMAIN: ${{ vars.VITE_MATOMO_APP_DOMAIN }}
VITE_OSM_HASHTAGS: ${{ vars.VITE_OSM_HASHTAGS }}
VITE_FAIR_PREDICTOR_API_URL: ${{ vars.VITE_FAIR_PREDICTOR_API_URL }}
VITE_MIN_TRAINING_AREA_SIZE: ${{ vars.VITE_MIN_TRAINING_AREA_SIZE }}
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_OIDC_ROLE }}
role-session-name: fAIrGithub
- name: Upload to S3
working-directory: ./frontend/dist
run: aws s3 sync . s3://${{ vars.FRONTEND_BUCKET }}/