try cloudfron changes #33
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: Build and deploy front end | |
on: | |
push: | |
branches: | |
- main | |
- "*" | |
- "feature/*" | |
paths: | |
- 'frontend/**' | |
- '.github/workflows/frontend.yml' | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- 'frontend/**' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install dependencies and run tests | |
run: | | |
cd frontend | |
npm ci | |
# npm test | |
- name: Set environment variables | |
run: | | |
echo "VITE_API_BASE_URL=${{ secrets.VITE_API_BASE_URL }}" >> $GITHUB_ENV | |
echo "VITE_COGNITO_DOMAIN=${{ secrets.VITE_COGNITO_DOMAIN }}" >> $GITHUB_ENV | |
echo "VITE_LOCAL_URL=${{ secrets.VITE_LOCAL_URL }}" >> $GITHUB_ENV | |
echo "VITE_CLIENT_ID=${{ secrets.VITE_CLIENT_ID }}" >> $GITHUB_ENV | |
echo "VITE_COGNITO_AUTHORITY=${{ secrets.VITE_COGNITO_AUTHORITY }}" >> $GITHUB_ENV | |
- name: Build React app | |
run: | | |
cd frontend | |
npm run build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY}} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-central-1 | |
- name: Deploy to S3 | |
run: | | |
aws s3 sync frontend/dist/ s3://${{ secrets.AWS_S3_BUCKET }}/ --delete | |