npm again #695
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: Build Docs | |
on: | |
push: | |
branches: [main, staging] | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
env: | |
BUCKET_NAME: ${{ github.ref == 'refs/heads/main' && 's3://www.fused.io/' || 's3://docs-staging.fused.io/' }} | |
CLOUDFRONT_ID: ${{ github.ref == 'refs/heads/main' && 'E2ZP0BRHQ20MYJ' || 'E33Z2H4C1WZOKH' }} | |
jobs: | |
publish-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Auth with OIDC: | |
# https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: arn:aws:iam::926411091187:role/github_website_role | |
role-session-name: GithubFusedLabsFusedPyReleaseDocs | |
aws-region: us-west-2 | |
- name: Use Node.js | |
id: setup-node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: current | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Install dependencies | |
run: npm install | |
- name: Build docs | |
run: npm run build | |
#-------------------------------# | |
# Push the website # | |
#-------------------------------# | |
# After running the build, copy the contents to the S3 bucket to be served, and invalidate the CloudFront cache so it starts serving the new content: | |
- name: Publish website | |
shell: bash | |
run: | | |
aws s3 sync ./build $BUCKET_NAME --delete | |
- name: Invalidate CloudFront distribution | |
shell: bash | |
run: | | |
aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_ID --paths '/*' |