File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5858 - name : Generate SvelteKit config
5959 run : pnpm svelte-kit sync
6060
61+ # - name: Set deployment status
62+ # if: steps.diff.outputs.db_changed == 'true'
63+ # env:
64+ # DB_URL: ${{ secrets.DB_URL }}
65+ # DB_AUTH_TOKEN: ${{ secrets.DB_AUTH_TOKEN }}
66+ # run: tsx scripts/deploy-status.ts --deploying
67+
6168 - name : Update database
6269 if : steps.diff.outputs.db_changed == 'true'
6370 env :
9299
93100 git tag -f deploy-prod $GITHUB_SHA
94101 git push --no-verify origin refs/tags/deploy-prod --force
102+
103+ - name : Reset deployment status
104+ if : always()
105+ env :
106+ DB_URL : ${{ secrets.DB_URL }}
107+ DB_AUTH_TOKEN : ${{ secrets.DB_AUTH_TOKEN }}
108+ run : pnpm db:finish-deploy
Original file line number Diff line number Diff line change 1+ CREATE TABLE deployment_status (
2+ id INTEGER PRIMARY KEY CHECK (id = 1 ),
3+ status TEXT NOT NULL CHECK (status IN (' ready' , ' deploying' )),
4+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
5+ );
6+
7+ INSERT INTO deployment_status (id, status) VALUES (1 , ' ready' );
Original file line number Diff line number Diff line change 2020 "db:deduce" : " tsx scripts/deduce.ts" ,
2121 "db:test" : " tsx scripts/test.ts" ,
2222 "db:update" : " pnpm db:migrate && pnpm db:seed && pnpm db:deduce && pnpm db:test" ,
23- "db:watch" : " tsx scripts/watch.ts"
23+ "db:watch" : " tsx scripts/watch.ts" ,
24+ "db:start-deploy" : " tsx scripts/deploy-status.ts --deploying" ,
25+ "db:finish-deploy" : " tsx scripts/deploy-status.ts --ready"
2426 },
2527 "devDependencies" : {
2628 "@sveltejs/adapter-netlify" : " ^6.0.4" ,
Original file line number Diff line number Diff line change 1+ import { createClient } from '@libsql/client'
2+ import dotenv from 'dotenv'
3+
4+ dotenv . config ( { quiet : true } )
5+ const DB_URL = process . env . DB_URL
6+ const DB_AUTH_TOKEN = process . env . DB_AUTH_TOKEN
7+
8+ if ( ! DB_URL ) throw new Error ( 'No DB_URL found' )
9+
10+ const db = createClient ( {
11+ url : DB_URL ,
12+ authToken : DB_AUTH_TOKEN ,
13+ } )
14+
15+ const status = process . argv [ 2 ] ?. slice ( 2 )
16+
17+ await db . execute (
18+ `
19+ UPDATE deployment_status SET
20+ status = ?,
21+ updated_at = CURRENT_TIMESTAMP
22+ WHERE id = 1
23+ ` ,
24+ [ status ] ,
25+ )
You can’t perform that action at this time.
0 commit comments