Skip to content

Commit

Permalink
Add delete-preview.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghislain89 committed Jun 10, 2024
1 parent 217ec55 commit 5c48f37
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

name: Remove deploy preview

permissions:
contents: read
statuses: write
pull-requests: write

env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_DOCS_ID }}

on:
pull_request:
types:
- closed

jobs:
delete-deployments:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
show-progress: false

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Hash branch name
uses: pplanel/hash-calculator-action@v1.3.1
id: hash_branch
with:
input: ${{ steps.extract_branch.outputs.branch }}
method: MD5

- name: Call the delete-deployment-preview.sh script
env:
META_TAG: ${{ steps.hash_branch.outputs.digest }}
run: |
bash ./scripts/delete-deployment-preview.sh
1 change: 1 addition & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ jobs:
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --archive=tgz | tee deploy.log

- name: Set preview url
if: steps.detectChanges.outputs.changed == 'true'
id: deployment
run: echo "url=$(tail -1 deploy.log)">> $GITHUB_OUTPUT

0 comments on commit 5c48f37

Please sign in to comment.