Skip to content

Commit 41e8ce4

Browse files
committed
ci: automate openapi artifact regeneration on release PRs
1 parent 4f1c416 commit 41e8ce4

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.github/release-please-config.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
"release-type": "ruby",
55
"package-name": "html2rss-web",
66
"version-file": "config/version.rb",
7-
"changelog-path": "CHANGELOG.md"
7+
"changelog-path": "CHANGELOG.md",
8+
"extra-files": [
9+
{
10+
"type": "json",
11+
"path": "frontend/package.json",
12+
"jsonpath": "$.version"
13+
},
14+
"public/openapi.yaml",
15+
"frontend/src/api/generated/client.gen.ts",
16+
"frontend/src/api/generated/sdk.gen.ts",
17+
"frontend/src/api/generated/types.gen.ts",
18+
"frontend/src/api/generated/index.ts"
19+
]
820
}
921
}
1022
}

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ jobs:
4949
runs-on: ubuntu-latest
5050
steps:
5151
- uses: actions/checkout@v6
52+
with:
53+
token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
5254

5355
- uses: ruby/setup-ruby@v1
5456
with:
@@ -71,7 +73,25 @@ jobs:
7173
working-directory: frontend
7274

7375
- name: Verify generated OpenAPI spec and client are up to date
76+
id: verify
7477
run: make openapi-verify
78+
continue-on-error: ${{ startsWith(github.head_ref, 'release-please--') }}
79+
80+
- name: Regenerate and commit OpenAPI artifacts on release PRs
81+
if: steps.verify.outcome == 'failure' && startsWith(github.head_ref, 'release-please--')
82+
run: |
83+
git config --global user.name "github-actions[bot]"
84+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
85+
86+
make openapi
87+
make openapi-client
88+
89+
git add public/openapi.yaml frontend/src/api/generated/
90+
git commit -m "chore: regenerate openapi spec and client for version bump"
91+
git push
92+
93+
echo "## OpenAPI artifacts regenerated" >> "$GITHUB_STEP_SUMMARY"
94+
echo "Version bump detected; OpenAPI spec and frontend client have been regenerated and committed." >> "$GITHUB_STEP_SUMMARY"
7595
7696
- name: Lint OpenAPI contract
7797
run: make openapi-lint

0 commit comments

Comments
 (0)