add manual dispatch and cloudfront invalidation #8
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: Test and Deploy | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: [ main ] | |
push: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Cypress Run | |
uses: cypress-io/github-action@v6 | |
with: | |
project: . | |
browser: chrome | |
build: npm run build | |
start: npm run dev | |
wait-on: "http://localhost:3000" | |
deploy: | |
runs-on: ubuntu:latest | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: npm | |
- name: Install Dependencies | |
run: npm i | |
- name: Build App | |
run: npm run build | |
- name: Sync to S3 | |
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: us-east-2 | |
- run: aws s3 sync ./out s3://mchewittwedding.com | |
- name: Invalidate Cloudfront | |
uses: chetan/[email protected] | |
env: | |
DISTRIBUTION: E1OUB9BRZ80YGI | |
PATHS: /* | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: us-east-2 |