-
Notifications
You must be signed in to change notification settings - Fork 293
35 lines (31 loc) · 1.08 KB
/
remove-preview-domain.yml
File metadata and controls
35 lines (31 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
name: Unassign preview-domain
on:
# Trigger when a pull request is closed
pull_request:
types: [closed]
permissions:
contents: read
jobs:
unassign-preview-domain:
runs-on: ubuntu-latest
steps:
- name: Prepare domain
id: prepare
uses: actions/github-script@v7.0.1
with:
script: |
const subdomain = `${{ github.head_ref }}`
.toLowerCase()
.slice(0, 32)
.replace(/[^a-z0-9-]/g, '-')
.replace(/^-+|-+$/g, '')
.replace(/-{2,}/g, '-')
const domain = `${subdomain}.${{ vars.PREVIEW_DOMAIN }}`
.toLowerCase()
.replaceAll("_","-")
core.setOutput('domain', domain)
- name: Unssign preview-domain
run: |
curl -sX DELETE "https://vercel.com/api/v10/projects/${{ secrets.VERCEL_PROJECT_ID }}/domains/${{ steps.prepare.outputs.domain }}?teamId=${{ secrets.VERCEL_TEAM_ID }}" \
-H "Authorization: Bearer ${{ secrets.VERCEL_BEARER_TOKEN }}" \
-H "Content-Type: application/json"