Update Docs (Mintlify) #164
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: Update Docs (Mintlify) | |
| on: | |
| workflow_run: | |
| workflows: ["Update NodeJS SDK"] | |
| types: | |
| - completed | |
| branches: | |
| - main | |
| jobs: | |
| update-docs: | |
| runs-on: ubuntu-latest | |
| # Run regardless of NodeJS SDK workflow outcome (success or failure) | |
| if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion != 'failure' }} | |
| steps: | |
| - name: Dump GitHub context # Makes it much easier to retrospectively debug all sorts of workflow issues. Does NOT expose secrets. | |
| env: | |
| GITHUB_CONTEXT: ${{ toJson(github) }} | |
| run: echo "$GITHUB_CONTEXT" | |
| - name: Generate Neynar CI Bot token | |
| id: generate-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ secrets.NEYNAR_CI_BOT_APP_ID }} | |
| private-key: ${{ secrets.NEYNAR_CI_BOT_PRIVATE_KEY }} | |
| owner: 'neynarxyz' | |
| repositories: 'docs' | |
| - name: Checkout OAS repository | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| - name: Checkout docs repository | |
| uses: actions/checkout@v3 | |
| with: | |
| repository: "neynarxyz/docs.git" | |
| ref: "main" | |
| path: "docs" | |
| token: ${{ steps.generate-token.outputs.token }} | |
| persist-credentials: true | |
| - name: Copy updated YAML files to docs repository | |
| run: | | |
| cp src/hub-api/spec.yaml docs/openapi/hub-api/openapi.yaml | |
| cp src/api/spec.yaml docs/openapi/api/openapi.yaml | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Generate Node.js SDK docs | |
| run: | | |
| cd docs | |
| node scripts/generate-nodejs-sdk-docs.js | |
| - name: Commit and push changes | |
| run: | | |
| # Get the author information from the OAS commit | |
| AUTHOR_NAME=$(git log -1 --format='%an') | |
| AUTHOR_EMAIL=$(git log -1 --format='%ae') | |
| cd docs | |
| # Set Git config using OAS commit author | |
| git config user.name "$AUTHOR_NAME (via Neynar CI Bot)" | |
| git config user.email "$AUTHOR_EMAIL" | |
| # Stage and commit any changes | |
| if git diff --quiet; then | |
| echo "No changes to commit." | |
| exit 0 | |
| fi | |
| git add . | |
| git commit -m "[GitHub Actions] Copy OpenAPI specs from OAS repo" | |
| # Push changes directly to main | |
| git push origin main | |
| echo "Successfully pushed documentation updates to docs repository" | |
| shell: bash |