diff options
| author | Aiden Cline <[email protected]> | 2025-12-18 14:33:40 -0600 |
|---|---|---|
| committer | Aiden Cline <[email protected]> | 2025-12-18 14:33:40 -0600 |
| commit | 8d11df1b3b9eb40510e0877318b238a7780a16fc (patch) | |
| tree | 20a457327f52d06484912b6480d999fae59abc0e /.github/workflows | |
| parent | ecc505083864bd0055e9cd23153d1021b6d202ca (diff) | |
| download | opencode-8d11df1b3b9eb40510e0877318b238a7780a16fc.tar.gz opencode-8d11df1b3b9eb40510e0877318b238a7780a16fc.zip | |
ci: handle case where generate.yml fails better
Diffstat (limited to '.github/workflows')
| -rw-r--r-- | .github/workflows/generate.yml | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 326090f7a..4836a78d6 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -14,6 +14,7 @@ jobs: runs-on: blacksmith-4vcpu-ubuntu-2404 permissions: contents: write + pull-requests: write steps: - name: Checkout repository uses: actions/checkout@v4 @@ -25,14 +26,30 @@ jobs: - name: Setup Bun uses: ./.github/actions/setup-bun - - name: Generate SDK + - name: Generate + run: ./script/generate.ts + + - name: Commit and push + id: push run: | - bun ./packages/sdk/js/script/build.ts - (cd packages/opencode && bun dev generate > ../sdk/openapi.json) - bun x prettier --write packages/sdk/openapi.json + if [ -z "$(git status --porcelain)" ]; then + echo "No changes to commit" + exit 0 + fi + git config --local user.email "[email protected]" + git config --local user.name "GitHub Action" + git add -A + git commit -m "chore: generate" + git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref_name }} --no-verify - - name: Format - run: ./script/format.ts + - name: Comment on failure + if: failure() + run: | + 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```' + if [ -n "${{ github.event.pull_request.number }}" ]; then + gh pr comment ${{ github.event.pull_request.number }} --body "$MESSAGE" + else + gh api repos/${{ github.repository }}/commits/${{ github.sha }}/comments -f body="$MESSAGE" + fi env: - CI: true - PUSH_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
