Skip to content

Update GraphQL files #935

Update GraphQL files

Update GraphQL files #935

name: Update GraphQL files
# **What it does**: This updates our GraphQL schemas.
# **Why we have it**: We want our GraphQL docs up to date.
# **Who does it impact**: Docs engineering, people reading GraphQL docs.
on:
workflow_dispatch:
schedule:
- cron: '20 16 * * *' # run every day at 16:20 UTC / 8:20 PST
permissions:
contents: write
pull-requests: write
# **IMPORTANT:** Do not change the FREEZE environment variable set here!
# This workflow runs on a recurring basis. To temporarily disable it (e.g.,
# during a docs deployment freeze), add an Actions Secret to the repo settings
# called `FREEZE` with a value of `true`. To re-enable GraphQL updates, simply
# delete that Secret from the repo settings. The environment variable here
# will duplicate that Secret's value for later evaluation.
env:
FREEZE: ${{ secrets.FREEZE }}
jobs:
update_graphql_files:
if: github.repository == 'github/docs-internal'
runs-on: ubuntu-latest
steps:
- if: ${{ env.FREEZE == 'true' }}
run: |
echo 'The repo is currently frozen! Exiting this workflow.'
exit 1 # prevents further steps from running
- name: Checkout
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
- name: Setup Node
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
with:
node-version: '16.17.0'
cache: npm
- name: Install Node.js dependencies
run: npm ci
- name: Run updater scripts
env:
# need to use a token from a user with access to github/github for this step
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }}
run: |
script/graphql/update-files.js
- name: Create pull request
id: create-pull-request
uses: peter-evans/create-pull-request@bd72e1b7922d417764d27d30768117ad7da78a0e
env:
# Disable pre-commit hooks; they don't play nicely here
HUSKY: '0'
with:
# Need to use a token with repo and workflow scopes for this step.
# Token should be a PAT because actions performed with GITHUB_TOKEN
# don't trigger other workflows and this action force pushes updates
# from the default branch.
token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
commit-message: 'Action ran graphql script"update-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 #docs-engineering on slack."
branch: graphql-schema-update
- name: Enable GitHub auto-merge
if: ${{ steps.create-pull-request.outputs.pull-request-number }}
env:
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}
AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }}
run: node .github/actions-scripts/enable-automerge.js
- if: ${{ failure() && env.FREEZE != 'true'}}
name: Delete remote branch (if previous steps failed)
uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: graphql-schema-update
- if: ${{ steps.create-pull-request.outputs.pull-request-number }}
name: Approve
uses: juliangruber/approve-pull-request-action@c67a4808d52e44ea03656f6646ba24a010304f03
with:
github-token: ${{ secrets.DOCUBOT_REPO_PAT }}
number: ${{ steps.create-pull-request.outputs.pull-request-number }}
- name: Send Slack notification if workflow fails
uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340
if: ${{ failure() && env.FREEZE != 'true' }}
with:
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
color: failure
text: The last update-graphql-files run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/update-graphql-files.yml