diff --git a/.github/workflows/generate-client-node.yaml b/.github/workflows/generate-client-node.yaml new file mode 100644 index 000000000..76b48bbb8 --- /dev/null +++ b/.github/workflows/generate-client-node.yaml @@ -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 }}