test that ci/cd is working for live site #141
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 `/dist` to Github pages | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- uses: actions/checkout@master | |
# Setup env | |
- name: "Create env file" | |
run: | | |
echo "${{ secrets.ENV_FILE }}" > .env | |
# Run build | |
- name: Use Node.js | |
uses: actions/setup-node@main | |
with: | |
node-version: 18.x | |
- name: Delete yarn.lock | |
run: rm yarn.lock | |
- name: Install dependencies | |
run: yarn install | |
- name: Build | |
run: yarn build | |
# Configure S3 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.S3_BUCKET_REGION }} | |
# Deploy to S3 | |
- name: Deploy to S3 bucket | |
run: aws s3 sync ./dist s3://${{ secrets.S3_BUCKET }}/dist/ | |
# Invalidate cloudront cache | |
- name: Invalidate Cloudfront cache | |
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |