fix: openapi #5
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: | ||
| pack: | ||
| runs-on: ubuntu-latest | ||
| environment: production | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| version: ${{ steps.set-outputs.outputs.version }} | ||
| packfile_name: ${{ steps.set-outputs.outputs.packfile_name }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: "20" | ||
| - id: set-outputs | ||
| name: Pack @docs/openapi and upload artifacts | ||
| run: | | ||
| set -euo pipefail | ||
| cd packages/openapi | ||
| echo "Working dir: $(pwd)" | ||
| cat package.json | ||
| npm ci | ||
| # npm pack prints the filename; grab the last non-empty line | ||
| PACKFILE=$(npm pack | sed -n '/./p' | tail -n1) | ||
| echo "Packed file: $PACKFILE" | ||
| # create stable 'latest' name | ||
| LATEST_NAME="openapi-latest.tgz" | ||
| cp -f "$PACKFILE" "$LATEST_NAME" | ||
| # ensure files exist | ||
| ls -la | ||
| VERSION=$(node -p "require('./package.json').version") | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
| echo "packfile_name=$PACKFILE" >> "$GITHUB_OUTPUT" | ||
| - name: Upload tarballs as artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: openapi-tarballs | ||
| path: | | ||
| packages/openapi/${{ steps.set-outputs.outputs.packfile_name }} | ||
| packages/openapi/openapi-latest.tgz | ||
| release_tag: | ||
| runs-on: ubuntu-latest | ||
| needs: pack | ||
| environment: production | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout (needed for workspace) | ||
| uses: actions/checkout@v4 | ||
| - name: Download packed artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: openapi-tarballs | ||
| path: artifacts | ||
| - name: Show artifacts (debug) | ||
| run: ls -la artifacts | ||
| - name: Create or update tagged release and upload versioned tarball | ||
| id: gh_release_tag | ||
| uses: softprops/action-gh-release@v1 | ||
| with: | ||
| tag_name: "openapi-v${{ needs.pack.outputs.version }}" | ||
| name: "openapi v${{ needs.pack.outputs.version }}" | ||
| body: "Automated release for packages/openapi (pack + upload)" | ||
| # artifact downloads put files under ./artifacts/<filename> | ||
| files: artifacts/${{ needs.pack.outputs.packfile_name }} | ||
| 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://github.com/@api/repos/$OPENAPI_REPO/dispatches \ | ||
| -d '{"event_type":"api-docs-release"}' | ||