Skip to content

Commit

Permalink
chore(cache): Implement a cache for docusaurus build
Browse files Browse the repository at this point in the history
  • Loading branch information
andromaqui committed Jul 10, 2024
1 parent 83f5aa3 commit da852ae
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/preview-env-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: preview-env-deploy
on:
pull_request:
types: [labeled, synchronize]
push:
branches:
- master

concurrency:
cancel-in-progress: true
Expand All @@ -17,6 +20,7 @@ jobs:
- uses: actions/checkout@v4

- name: Import secrets from Vault
if: github.ref != 'refs/heads/main'
id: secrets
uses: hashicorp/vault-action@d1720f055e0635fd932a1d2a48f87a666a57906c
with:
Expand All @@ -38,15 +42,26 @@ jobs:
DOCS_SITE_BASE_URL: /pr-${{ github.event.number }}/
run: npm run build

- name: Create docusaurus cache
uses: actions/cache/save@v4
with:
path: |
.docusaurus
/**/.cache
key: ${{ runner.os }}-docusaurus-dummytest

- name: Authenticate with Google Cloud
if: github.ref != 'refs/heads/main'
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ steps.secrets.outputs.PREVIEW_ENV_GCLOUD_SA_KEY }}

- name: Set up Cloud SDK
if: github.ref != 'refs/heads/main'
uses: google-github-actions/setup-gcloud@v2

- name: Start Deployment
if: github.ref != 'refs/heads/main'
uses: bobheadxi/deployments@v1
id: deployment
with:
Expand All @@ -56,12 +71,14 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}

- name: Upload files to Google bucket
if: github.ref != 'refs/heads/main'
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
run: |
gsutil -m rsync -d -r build gs://$BUCKET_NAME/pr-${{ github.event.number }}
- uses: bobheadxi/deployments@v1
if: github.ref != 'refs/heads/main'
with:
step: finish
token: ${{ github.token }}
Expand All @@ -71,16 +88,19 @@ jobs:
env_url: https://${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}/pr-${{ github.event.number }}/index.html

- name: Shorten commit SHA
if: github.ref != 'refs/heads/main'
run: echo "short_sha=$(echo ${{ github.sha }} | cut -c1-8)" >> $GITHUB_ENV

- name: Find previous deployment or tear-down comment
if: github.ref != 'refs/heads/main'
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.number }}
body-includes: <!-- preview-env -->

- name: Upsert deployment comment
if: github.ref != 'refs/heads/main'
uses: peter-evans/create-or-update-comment@v4
env:
BUCKET_NAME: ${{ steps.secrets.outputs.PREVIEW_ENV_BUCKET_NAME }}
Expand Down

0 comments on commit da852ae

Please sign in to comment.