Skip to content

Merge pull request #160 from toggle-corp/update-designation #29

Merge pull request #160 from toggle-corp/update-designation

Merge pull request #160 from toggle-corp/update-designation #29

Workflow file for this run

name: CD
on:
push:
# NOTE: Don't add other branches
branches:
- develop
jobs:
test_build:
if: github.event_name == 'push'
name: Run Tests + Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Run yarn install
run: yarn install
- name: Build + Test
run: yarn export
env:
NODE_OPTIONS: --max_old_space_size=4096
NEXT_PRIVATE_STANDALONE: true
- name: Upload GH artifacts
uses: actions/upload-pages-artifact@v1
with:
path: out/
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: out/
name: client-build
staging_deploy:
name: Deploy (STAGING)
needs: test_build
runs-on: ubuntu-latest
if: github.event_name == 'push'
permissions:
contents: write
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages 🚀
id: deployment
uses: actions/deploy-pages@v2
prod_deploy:
name: Deploy (PROD)
needs: [test_build, staging_deploy]
runs-on: ubuntu-latest
if: github.event_name == 'push'
environment:
name: prod
url: https://togglecorp.com
steps:
- uses: actions/download-artifact@v3
with:
name: client-build
path: ./out
# Copy build to S3
- name: S3 Sync
uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: './out'
# Invalidate Cloudfront (this action)
- name: Cloudfront Invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/*'