-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (34 loc) · 1008 Bytes
/
database_cleanup.yml
File metadata and controls
37 lines (34 loc) · 1008 Bytes
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
36
37
name: Cleanup Database Branch
on:
pull_request:
types:
- closed
workflow_dispatch:
inputs:
pr_number:
description: "Pull Request Number"
required: false
type: number
jobs:
cleanup_database:
runs-on: ubuntu-latest
steps:
- name: Install Turso CLI
run: |
curl -sSfL https://get.tur.so/install.sh | bash
echo "$HOME/.turso" >> $GITHUB_PATH
- name: Get DB Name
run: |
PR_NUM="${{ github.event.inputs.pr_number || github.event.pull_request.number }}"
if [ -z "$PR_NUM" ]; then
echo "No PR number provided"
exit 1
fi
DB_NAME="pr-$PR_NUM"
echo "DB_NAME=$DB_NAME" >> $GITHUB_ENV
- name: Destroy Turso Database
env:
TURSO_API_TOKEN: ${{ secrets.TURSO_API_TOKEN }}
DB_NAME: ${{ env.DB_NAME }}
run: |
turso db destroy "$DB_NAME" --yes || echo "Database already gone or never existed"