Skip to content

Commit

Permalink
unlink preview domains when PRs get closed (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlanz authored Jan 3, 2024
1 parent 8e92c4a commit 483d8d7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Preview

on:
pull_request:
types: [opened, reopened, synchronize]
types: [opened, reopened, synchronize, closed]

env:
NODE_VERSION: 16
Expand All @@ -16,6 +16,7 @@ jobs:
checks:
runs-on: ubuntu-22.04
timeout-minutes: 10
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
steps:
- uses: actions/checkout@v3
- uses: aboutbits/github-actions-node/setup-and-install@v1
Expand All @@ -31,6 +32,7 @@ jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 10
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
steps:
- uses: actions/checkout@v3
- uses: aboutbits/github-actions-node/setup-and-install@v1
Expand All @@ -43,7 +45,7 @@ jobs:
comment-link:
runs-on: ubuntu-22.04
timeout-minutes: 5
if: ${{ github.event.action == 'opened' }}
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
steps:
- uses: actions/github-script@v6
with:
Expand All @@ -58,6 +60,7 @@ jobs:
deploy-preview:
runs-on: ubuntu-22.04
timeout-minutes: 20
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize' }}
needs:
- checks
- test
Expand All @@ -78,3 +81,18 @@ jobs:
vercel-scope: aboutbits
deployment-domain: ${{ steps.deploy.outputs.url }}
preview-domain: ${{ github.event.pull_request.number }}.${{ env.PREVIEW_DOMAIN }}

unlink-domain:
runs-on: ubuntu-22.04
timeout-minutes: 10
if: ${{ github.event.action == 'closed' }}
steps:
- uses: actions/checkout@v3
- uses: aboutbits/github-actions-node/setup-and-install@v1
with:
node-version: ${{ env.NODE_VERSION }}
- uses: aboutbits/github-actions-vercel/unlink-domain@v1
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-scope: ${{ env.VERCEL_SCOPE }}
preview-domain: ${{ github.event.pull_request.number }}.${{ env.PREVIEW_DOMAIN }}

0 comments on commit 483d8d7

Please sign in to comment.