Sync & Publish #12
This file contains hidden or 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
| name: Sync & Publish | |
| on: | |
| repository_dispatch: | |
| types: [nixopus-api-updated] | |
| workflow_dispatch: | |
| jobs: | |
| sync-and-publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Fetch OpenAPI spec from nixopus | |
| run: | | |
| curl -sL "https://raw.githubusercontent.com/raghavyuva/nixopus/master/api/doc/openapi.json" -o openapi.json | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Generate client | |
| run: yarn generate | |
| - name: Build | |
| run: yarn build | |
| - name: Publish to npm | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| npm version patch --no-git-tag-version --allow-same-version | |
| npm publish --access public --no-git-tag-version | |
| - name: Commit and push generated files | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add src package.json | |
| git status | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: sync with nixopus OpenAPI spec [skip ci]" | |
| git push | |
| fi |