Merge pull request #175 from ajfisher/dependabot/npm_and_yarn/babel/t… #202
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: Build and deploy site | |
on: [ push ] | |
jobs: | |
build: | |
name: Build the site code | |
runs-on: ubuntu-latest | |
env: | |
GATSBY_TAGS_MODULES: ./site/plugins/gatsby-transformer-remark-tags/node_modules | |
GATSBY_PULLQUOTE_MODULES: ./site/plugins/gatsby-remark-transformer-pullquotes/node_modules | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache site node modules | |
id: cache-site-modules | |
uses: actions/cache@v3 | |
with: | |
path: ./site/node_modules | |
key: site-build-${{hashFiles('**/site/package-lock.json')}} | |
restore-keys: site-build-${{hashFiles('**/site/package-lock.json')}} | |
- name: Install site deps | |
if: steps.cache-site-modules.outputs.cache-hit != 'true' | |
run: cd site && npm install | |
- name: Cache Tags plugin node modules | |
id: cache-tags-modules | |
uses: actions/cache@v3 | |
with: | |
path: ${{env.GATSBY_TAGS_MODULES}} | |
key: site-tags-${{hashFiles('**/gatsby-transformer-remark-tags/package-lock.json')}} | |
restore-keys: site-tags-${{hashFiles('**/gatsby-transformer-remark-tags/package-lock.json')}} | |
- name: Install tags deps | |
if: steps.cache-tags-modules.outputs.cache-hit != 'true' | |
run: cd site/plugins/gatsby-transformer-remark-tags && npm install | |
- name: Cache pullquotes plugin node modules | |
id: cache-pullquotes-modules | |
uses: actions/cache@v3 | |
with: | |
path: ${{env.GATSBY_PULLQUOTE_MODULES}} | |
key: site-tags-${{hashFiles('**/gatsby-remark-transformer-pullquotes/package-lock.json')}} | |
restore-keys: site-tags-${{hashFiles('**/gatsby-remark-transformer-pullquotes/package-lock.json')}} | |
- name: Install pullquote deps | |
if: steps.cache-pullquotes-modules.outputs.cache-hit != 'true' | |
run: cd site/plugins/gatsby-remark-transformer-pullquotes && npm install | |
- name: Public output | |
id: public-build | |
uses: actions/cache@v3 | |
with: | |
path: ./site/public | |
key: site-public-${{hashFiles('**/site/public/**')}} | |
restore-keys: site-public- | |
- name: Gatsby Cache output | |
id: cache-build | |
uses: actions/cache@v3 | |
with: | |
path: ./site/.cache | |
key: site-cache-${{hashFiles('**/site/.cache/**')}} | |
restore-keys: site-cache- | |
- name: Build output files | |
run: make build | |
env: | |
GATSBY_EXPERIMENTAL_PAGE_BUILD_ON_DATA_CHANGES: true | |
- name: Configure AWS CLI | |
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: ap-southeast-2 | |
if: github.ref == 'refs/heads/master' | |
- name: Sync files to S3 | |
run: aws s3 sync ./site/public/ s3://aj-web-ajfisher-me-prod/ --delete | |
if: github.ref == 'refs/heads/master' |