Updated dependencies. Removed some public files that will now host fr… #27
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 Static Content to S3 | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: # Allows manual triggering of workflow | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get short SHA | |
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV | |
- name: Get subfolder name | |
run: | | |
CURRENT_DATE=$(date +"%Y-%m") | |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7) | |
echo "SUBFOLDER_NAME=${CURRENT_DATE}-${SHORT_SHA}" >> $GITHUB_ENV | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '16' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build static content | |
run: npm run build | |
env: | |
PUBLIC_URL: /${{ env.SUBFOLDER_NAME }} | |
- name: Update redirection URL. | |
run: sed -i "s|%PUBLIC_URL%|/${{ env.SUBFOLDER_NAME }}|" build/root-redirect.html | |
- name: Store rollback information. | |
run: aws s3 cp s3://wisp.studio/index.html s3://wisp.studio/rollback.html | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: 'us-east-1' | |
- name: Deploy to S3 using AWS CLI | |
run: | | |
echo "Deploying commit ${{ github.sha }} to S3..." | |
aws s3 sync build s3://wisp.studio/${{ env.SUBFOLDER_NAME }} --delete | |
aws s3 cp build/root-redirect.html s3://wisp.studio/index.html | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: 'us-east-1' |