Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ on:
permissions:
contents: read
pull-requests: write
environments: write

concurrency:
group: >-
Expand Down Expand Up @@ -455,6 +454,9 @@ jobs:
github.event.pull_request.head.repo.fork == false) ||
(github.event_name == 'workflow_dispatch' &&
inputs.action == 'cleanup')
env:
PREVIEW_ENVIRONMENT_GITHUB_TOKEN:
${{ secrets.PREVIEW_ENVIRONMENT_GITHUB_TOKEN }}
steps:
- name: 📦 Checkout
uses: actions/checkout@v6.0.2
Expand Down Expand Up @@ -569,15 +571,26 @@ jobs:
set -euo pipefail
node tools/ci/preview-resources.ts cleanup --worker-name "$APP_WORKER_NAME"

- name: ℹ️ Skip GitHub preview environment delete
if: >-
always() &&
env.PREVIEW_ENVIRONMENT_GITHUB_TOKEN == ''
run: >
echo "Skipping GitHub preview environment delete;
PREVIEW_ENVIRONMENT_GITHUB_TOKEN is not configured."

- name: 🏷️ Delete GitHub preview environment
if: always()
if: >-
always() &&
env.PREVIEW_ENVIRONMENT_GITHUB_TOKEN != ''
uses: actions/github-script@v8.0.0
env:
EVENT_NAME: ${{ github.event_name }}
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
INPUT_TARGET: ${{ inputs.target }}
INPUT_PR_NUMBER: ${{ inputs.pr_number }}
with:
github-token: ${{ env.PREVIEW_ENVIRONMENT_GITHUB_TOKEN }}
script: |
const eventName = process.env.EVENT_NAME;
let envName;
Expand Down
Loading