Repository navigation
Sync GraphQL schema #1190
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 GraphQL schema | |
| # Keeps GraphQL docs current with schema changes from github/github. | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '20 16 * * 1-5' # Run Mon-Fri at 16:20 UTC / 8:20 PST | |
| permissions: | |
| contents: read | |
| jobs: | |
| update_graphql_files: | |
| if: github.repository == 'github/docs-internal' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| outputs: | |
| ignored-changes: ${{ steps.sync.outputs.ignored-changes }} | |
| ignored-count: ${{ steps.sync.outputs.ignored-count }} | |
| ignored-types: ${{ steps.sync.outputs.ignored-types }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/node-npm-setup | |
| - name: Run updater scripts | |
| id: sync | |
| env: | |
| # DOCS_BOT_PAT_BASE can read github/github. | |
| GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| NODE_OPTIONS: '--max-old-space-size=8192' | |
| run: npm run sync-graphql | |
| - name: Create pull request | |
| id: create-pull-request | |
| uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # pin @v8.0.0 | |
| env: | |
| # Disable Husky because create-pull-request commits inside Actions. | |
| HUSKY: '0' | |
| with: | |
| # DOCS_BOT_PAT_BASE has repo and workflow scopes. | |
| # GITHUB_TOKEN does not trigger follow-up workflows. | |
| # create-pull-request force-pushes updates from the default branch. | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| commit-message: 'Update GraphQL data files' | |
| title: GraphQL schema update | |
| body: | |
| "Hello! Some GraphQL data in github/github was updated recently. This PR | |
| syncs up the GraphQL data in this repo.\n\n | |
| If CI passes, this PR will be auto-merged. :green_heart:\n\n | |
| If CI does not pass or other problems arise, contact #technical-content on slack." | |
| branch: graphql-schema-update | |
| - name: Enable GitHub auto-merge | |
| if: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
| run: npm run enable-automerge | |
| - if: ${{ failure() }} | |
| name: Delete remote branch (if previous steps failed) | |
| run: git push origin --delete graphql-schema-update | |
| - if: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
| name: Approve | |
| uses: juliangruber/approve-pull-request-action@68fcc9a5a73b5641cadf757cf99d73720dcb05d0 # v2.1.0 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| number: ${{ steps.create-pull-request.outputs.pull-request-number }} | |
| - uses: ./.github/actions/create-workflow-failure-issue | |
| id: create-failure-issue | |
| if: ${{ failure() && github.event_name != 'workflow_dispatch' }} | |
| with: | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| - uses: ./.github/actions/slack-alert | |
| if: ${{ failure() && github.event_name != 'workflow_dispatch' }} | |
| with: | |
| slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} | |
| issue_url: ${{ steps.create-failure-issue.outputs.issue_url }} | |
| notify_ignored_changes: | |
| if: github.repository == 'github/docs-internal' && needs.update_graphql_files.outputs.ignored-count > 0 && github.event_name != 'workflow_dispatch' | |
| needs: update_graphql_files | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - uses: ./.github/actions/slack-alert | |
| with: | |
| slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} | |
| message: | | |
| :graphql: GraphQL Sync found ${{ needs.update_graphql_files.outputs.ignored-count }} ignored change types: ${{ needs.update_graphql_files.outputs.ignored-types }} | |
| These change types are not in CHANGES_TO_REPORT and were silently ignored. Consider reviewing if they should be added to the changelog. | |
| See workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| - uses: ./.github/actions/create-workflow-failure-issue | |
| if: ${{ failure() && github.event_name != 'workflow_dispatch' }} | |
| with: | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} |