diff --git a/.github/workflows/build-docs-preview.yml b/.github/workflows/build-docs-preview.yml index fb6c01e67d6..ca1645c93b9 100644 --- a/.github/workflows/build-docs-preview.yml +++ b/.github/workflows/build-docs-preview.yml @@ -3,7 +3,7 @@ name: Build Docs Preview on: pull_request: branches: [master] - types: [opened, synchronize, reopened] + types: [opened, synchronize, reopened, closed] paths: - 'content/**' - 'assets/**' @@ -38,27 +38,32 @@ jobs: # plus objects.githubusercontent.com must be in allowed-endpoints or the # build dies at module resolution. - name: Harden Runner + if: github.event.action != 'closed' uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4 with: egress-policy: audit - name: Checkout PR + if: github.event.action != 'closed' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false submodules: recursive - name: Setup Go + if: github.event.action != 'closed' uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version-file: go.mod - name: Setup Node + if: github.event.action != 'closed' uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 with: node-version: "22" - name: Install dependencies + if: github.event.action != 'closed' run: | if [ -f package-lock.json ] || [ -f npm-shrinkwrap.json ]; then npm ci @@ -67,6 +72,7 @@ jobs: fi - name: Build PR preview + if: github.event.action != 'closed' env: HUGO_PREVIEW: "true" BASE_URL: /pr-preview/pr-${{ github.event.pull_request.number }}/ diff --git a/.github/workflows/deploy-docs-preview.yml b/.github/workflows/deploy-docs-preview.yml index 461ffc5cd8f..c3f1d6cd4f6 100644 --- a/.github/workflows/deploy-docs-preview.yml +++ b/.github/workflows/deploy-docs-preview.yml @@ -46,7 +46,7 @@ jobs: run: | ACTION=$(head -n1 temp-artifact/pr/action 2>/dev/null | tr -d '[:space:]') case "$ACTION" in - opened|reopened|synchronize) ;; + opened|reopened|synchronize|closed) ;; *) echo "::error::invalid or missing action: '$ACTION'"; exit 1 ;; esac @@ -72,7 +72,7 @@ jobs: umbrella-dir: pr-preview pr-number: ${{ steps.meta.outputs.pr_number }} pages-base-url: docs.layer5.io - action: deploy + action: ${{ steps.meta.outputs.action == 'closed' && 'remove' || 'deploy' }} wait-for-pages-deployment: false comment: false @@ -82,8 +82,9 @@ jobs: header: pr-preview number: ${{ steps.meta.outputs.pr_number }} message: | - 🚀 Preview deployment: https://docs.layer5.io/pr-preview/pr-${{ steps.meta.outputs.pr_number }}/ - > *Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment [here](https://github.com/${{ github.repository }}/actions/workflows/pages/pages-build-deployment)* + ${{ steps.meta.outputs.action == 'closed' && 'Preview removed because the pull request was closed.' + || format('🚀 Preview deployment: https://docs.layer5.io/pr-preview/pr-{0}/ + > *Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment [here](https://github.com/{1}/actions/workflows/pages/pages-build-deployment)*', steps.meta.outputs.pr_number, github.repository) }} prune: # Both jobs push to gh-pages, but only prune retries a lost race, so deploy