hidivelab.org website setup #376
Workflow file for this run
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 to S3 | |
on: [push, pull_request] | |
jobs: | |
build: | |
# Available versions: | |
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on | |
runs-on: ubuntu-20.04 | |
env: | |
#sassc 2.2.1 which is a dependency of uswds-jekyll has issues with Ubuntu. | |
#see https://github.com/sass/sassc-ruby/issues/146#issuecomment-542288556. | |
BUNDLE_BUILD__SASSC: "--disable-march-tune-native" | |
# These permissions are needed to interact with GitHub's OIDC Token endpoint. | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node 12 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '12' | |
cache: 'npm' | |
- name: Install node dependencies | |
run: npm install | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.7.3' | |
bundler-cache: true | |
- name: Build Jekyll | |
run: | | |
set -e | |
bundle exec jekyll build | |
! grep -n '<ERROR' -r _site | |
bundle exec htmlproofer --alt-ignore '/.*/' --check-html --disable-external --assume-extension ./_site | |
- name: check ref | |
run: | | |
echo ${{github.ref}} | |
- name: Configure AWS Credentials | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/lchoy/website-migration' }} | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: ${{ secrets.AWS_IAM_ROLE }} | |
aws-region: us-east-1 | |
- name: Upload to S3 | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/lchoy/website-migration' }} | |
run: | | |
aws s3 sync _site/ s3://hidivelab.org | |
- name: Invalidate Cache | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/lchoy/website-migration' }} | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{secrets.CF_DISTRIBUTION_ID}} --paths "/*" |