chore: test deploy #2
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: Deploy Openapi Assets | |
| on: | |
| push: | |
| branches: [feat-openapi-package] | |
| paths: | |
| - "packages/openapi/**" | |
| jobs: | |
| deploy-package: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| permissions: | |
| # needed to create/update releases and upload assets | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - id: pack | |
| name: Pack @docs/openapi | |
| run: | | |
| cd packages/openapi | |
| # Install, then create a packed tarball; capture version & filename | |
| npm ci | |
| VERSION=$(node -p "require('./package.json').version") | |
| PACKFILE=$(npm pack | tail -n1) | |
| # export step outputs for later steps | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # NOTE: packfile_name is just the filename (e.g. openapi-1.2.3.tgz) | |
| echo "packfile_name=$PACKFILE" >> $GITHUB_OUTPUT | |
| # tarball is the absolute path to the produced file | |
| echo "tarball=$PWD/$PACKFILE" >> $GITHUB_OUTPUT | |
| - name: Create or update release and upload tarball | |
| id: gh_release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| # tag format - adjust if you prefer plain "v${{ steps.pack.outputs.version }}" | |
| tag_name: "openapi-v${{ steps.pack.outputs.version }}" | |
| name: "openapi v${{ steps.pack.outputs.version }}" | |
| body: "Automated release for packages/openapi (pack + upload)" | |
| # softprops accepts a whitespace or comma separated list of files/globs | |
| files: ${{ steps.pack.outputs.tarball }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| rebuild-schema: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| needs: | |
| - deploy-package | |
| steps: | |
| - name: Trigger autoupdate swagger | |
| env: | |
| GH_ORG_ACCESS_TOKEN: ${{ secrets.GH_ORG_ACCESS_TOKEN }} | |
| OPENAPI_REPO: ${{ secrets.OPENAPI_REPO }} | |
| run: | | |
| curl -X POST \ | |
| -H "Authorization: Bearer $GH_ORG_ACCESS_TOKEN" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/$OPENAPI_REPO/dispatches \ | |
| -d '{"event_type":"api-docs-release"}' |