-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #354 from openmeterio/ci/node-client-generation
ci(api): add Node.js client generation workflow
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Node.js Client Generation | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+-dev.[0-9]+" | ||
- "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" | ||
paths: | ||
- api/openapi.yaml | ||
- ".github/workflows/generate-node-client.yaml" | ||
|
||
env: | ||
NEW_BRANCH: openapi-${GITHUB_SHA::7}/node-clientgen | ||
|
||
jobs: | ||
generate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout new Branch | ||
run: git checkout -b ${{ env.NEW_BRANCH }} | ||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20" | ||
cache: "npm" | ||
cache-dependency-path: "./api/client/node/package-lock.json" | ||
- name: Install Dependencies | ||
run: npm ci | ||
working-directory: ./api/client/node | ||
- name: Generate Client | ||
run: npm run generate | ||
working-directory: ./api/client/node | ||
- name: Bump Version | ||
run: | | ||
npm version patch -m "chore(api): bump Node.js client version to %s" | ||
working-directory: ./api/client/node | ||
- name: Commit and push changes | ||
run: | | ||
git config --global user.email "github-actions[bot]" | ||
git config --global user.name "github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "chore(api): generate node client" | ||
git push origin ${{ env.NEW_BRANCH }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Open PR | ||
run: | | ||
gh pr create \ | ||
--title "[bot] Re-generate Node.js client" \ | ||
--body "This PR was automatically generated." \ | ||
--base main \ | ||
--head ${{ env.NEW_BRANCH }} \ | ||
--repo ${{ github.repository }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |