-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (77 loc) · 2.46 KB
/
pocketbase-typegen.yml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Generate pocketbase types
# PR opened, closed or updated
on:
push:
branches:
- main
jobs:
typegen:
name: Generate pocketbase types
runs-on: ubuntu-latest
outputs:
# https://github.com/orgs/community/discussions/25280
commit_changes: ${{ steps.check_changes.outputs.commit_changes }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Generate types
env:
PUBLIC_PB_HOST: ${{ vars.PB_HOST }}
PB_ADMIN_PASSWORD: ${{ secrets.PB_ADMIN_PASSWORD }}
PB_ADMIN_EMAIL: ${{ secrets.PB_ADMIN_EMAIL }}
run: make pb_types
- name: Upload generated types
uses: actions/upload-artifact@v4
with:
name: generated-types
path: src/lib/pocketbase/index.d.ts
- name: Check for changes
id: check_changes
run: |
# https://stackoverflow.com/a/62213712
if [ $(git status --porcelain | wc -l ) -gt 0 ]; then
echo 'commit_changes=true' >> $GITHUB_OUTPUT
else
echo 'commit_changes=false' >> $GITHUB_OUTPUT
fi
pr:
name: Create pull request
needs: [typegen]
if: needs.typegen.outputs.commit_changes == true
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download generated types
uses: actions/download-artifact@v4
with:
name: generated-types
path: src/lib/pocketbase/
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Set branch name
run: |
echo "branch=typegen-$(date +%s)" >> $GITHUB_ENV
- name: Commit and push changes
run: |
git checkout -b "$branch"
git add --force src/lib/pocketbase/index.d.ts
git commit -m "chore: update pocketbase types"
git push origin "$branch"
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create --base "main" \
--head "$branch" \
--title "Update pocketbase types" \
--body "Updated at $(date -Iminutes)" \
--label "typegen"