Sync Demo-Web html to S3 #4
This file contains hidden or 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: Sync Demo-Web html to S3 | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| paths: | |
| - "frontend/**" | |
| workflow_dispatch: | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_HYUDDPS_WEB_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_HYUDDPS_WEB_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: "us-west-2" | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| cache-dependency-path: './frontend/package-lock.json' | |
| - name: Install dependencies | |
| run: | | |
| cd frontend | |
| npm ci | |
| - name: Build Next.js app | |
| run: | | |
| cd frontend | |
| npm run build | |
| - name: "Sync with AWS S3" | |
| run: aws s3 sync ./frontend/out/ s3://${{ secrets.AWS_SPOTLAKE_S3_BUCKET_NAME }} --acl public-read --delete | |
| - name: Fix routes | |
| run: | | |
| export S3_BUCKET=${{ secrets.AWS_SPOTLAKE_S3_BUCKET_NAME }} | |
| find ./frontend/out -type f -name '*.html' | while read HTMLFILE; do | |
| BASENAME=${HTMLFILE##*/}; | |
| FILENAME=${BASENAME%.*}; | |
| if [[ "$FILENAME" != "index" ]]; then | |
| aws s3 cp s3://${S3_BUCKET}/${BASENAME} s3://${S3_BUCKET}/${FILENAME} --acl public-read; | |
| fi | |
| done | |
| - name: "Create Invalidation" | |
| run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_SPOTLAKE_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |