-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (38 loc) · 1.25 KB
/
register-articles-to-d1.yaml
File metadata and controls
40 lines (38 loc) · 1.25 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
36
37
38
39
40
name: Register Articles to D1
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Run Migration
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: d1 migrations apply blog-iine-counter
- name: Make Register Query
run: |
QUERY=""
FILENAMES=$(for file in src/markdown/posts/*.md;do if [ -f "$file" ]; then base=$(basename "$file" .md); echo $base; fi;done)
for filename in $FILENAMES; do
QUERY="$QUERY INSERT OR IGNORE INTO articles (id) VALUES ('$filename');";
done
echo "query=$QUERY" >> $GITHUB_ENV
- name: Register Articles to D1
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: d1 execute blog-iine-counter --remote --command "${{ env.query }}"
packageManager: pnpm