Skip to content

Update API Spec

Update API Spec #214

name: Update API Spec
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
check-generate-publish:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: '10.20.0'
run_install: false
- name: Install dependencies
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Run generate & check for changes
id: generate
run: |
npm run generate
if [ -n "$(git status --porcelain)" ]; then
echo "changes_detected=true" >> $GITHUB_OUTPUT
echo "Changes detected after generation"
else
echo "changes_detected=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Bump version
if: steps.generate.outputs.changes_detected == 'true'
id: version
run: |
NEW_VERSION=$(npm version patch --no-git-tag-version)
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Bumped to $NEW_VERSION"
- name: Build
if: steps.generate.outputs.changes_detected == 'true'
run: npm run build
- name: Publish to NPM
if: steps.generate.outputs.changes_detected == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Commit and push changes
if: steps.generate.outputs.changes_detected == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "upd: openapi spec ${{ steps.version.outputs.new_version }}"
git push origin main