1414 runs-on : blacksmith-4vcpu-ubuntu-2404
1515 permissions :
1616 contents : write
17+ pull-requests : write
1718 steps :
1819 - name : Checkout repository
1920 uses : actions/checkout@v4
@@ -25,14 +26,30 @@ jobs:
2526 - name : Setup Bun
2627 uses : ./.github/actions/setup-bun
2728
28- - name : Generate SDK
29+ - name : Generate
30+ run : ./script/generate.ts
31+
32+ - name : Commit and push
33+ id : push
2934 run : |
30- bun ./packages/sdk/js/script/build.ts
31- (cd packages/opencode && bun dev generate > ../sdk/openapi.json)
32- bun x prettier --write packages/sdk/openapi.json
35+ if [ -z "$(git status --porcelain)" ]; then
36+ echo "No changes to commit"
37+ exit 0
38+ fi
39+ git config --local user.email "action@github.com"
40+ git config --local user.name "GitHub Action"
41+ git add -A
42+ git commit -m "chore: generate"
43+ git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref_name }} --no-verify
3344
34- - name : Format
35- run : ./script/format.ts
45+ - name : Comment on failure
46+ if : failure()
47+ run : |
48+ MESSAGE=$'Failed to push generated code. Please run locally and push:\n```\n./script/generate.ts\ngit add -A && git commit -m "chore: generate" && git push\n```'
49+ if [ -n "${{ github.event.pull_request.number }}" ]; then
50+ gh pr comment ${{ github.event.pull_request.number }} --body "$MESSAGE"
51+ else
52+ gh api repos/${{ github.repository }}/commits/${{ github.sha }}/comments -f body="$MESSAGE"
53+ fi
3654 env :
37- CI : true
38- PUSH_BRANCH : ${{ github.event.pull_request.head.ref || github.ref_name }}
55+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments