Skip to content

Delete preview docs #79

Delete preview docs

Delete preview docs #79

name: Delete preview docs
on:
workflow_dispatch:
delete:
jobs:
delete:
name: Delete Vercel Project
if: github.event.ref_type == 'branch'
runs-on: ubuntu-latest
env:
BRANCH_NAME: ${{ github.event.ref }}
steps:
- run: |
set -euo pipefail
# ie, normalize the branch name to have no /, no upper, < 80 chars and only - as separator
preview_name=$(printf '%s' "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//; s/-+/-/g' | cut -c1-80)
preview_name="${preview_name:-preview}"
# Set up Vercel
npm install --global vercel@latest
# Pull Vercel environment
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
# Delete vercel project linked to this branch
vercel remove edsnlp-${preview_name} --yes --token=${{ secrets.VERCEL_TOKEN }}