70 lines
2.9 KiB
YAML
70 lines
2.9 KiB
YAML
name: Update GraphQL files
|
|
|
|
# **IMPORTANT:** Do not change the FREEZE environment variable set here.
|
|
# This workflow runs every hour. To temporarily disable it (for example, during
|
|
# a docs freeze), add a secret to the docs repo settings called `FREEZE`
|
|
# with a value of `true`. To reenable GraphQL updates, delete the secret in
|
|
# the repo settings. The env variable here will evaluate whether the secret exists.
|
|
env:
|
|
FREEZE: ${{ secrets.FREEZE }}
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: '20 16 * * *' # run every day at 16:20 UTC / 8:20 PST
|
|
|
|
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@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
|
- name: Set up Ruby
|
|
uses: actions/setup-ruby@5f29a1cd8dfebf420691c4c9a0e832e2fae5a526
|
|
with:
|
|
ruby-version: '2.4'
|
|
- name: Install Ruby dependencies
|
|
run: |
|
|
gem install bundler
|
|
bundle install
|
|
- 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.RACHMARI_REPO_WORKFLOW }}
|
|
run: |
|
|
script/graphql/update-files.js
|
|
- name: Create pull request
|
|
id: create-pull-request
|
|
uses: peter-evans/create-pull-request@8c603dbb04b917a9fc2dd991dc54fef54b640b43
|
|
with:
|
|
# need to use a token with repo and workflow scopes for this step
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
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."
|
|
labels: automerge
|
|
branch: graphql-schema-update
|
|
- if: ${{ failure() }}
|
|
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@c530832d4d346c597332e20e03605aa94fa150a8
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
number: ${{ steps.create-pull-request.outputs.pull-request-number }}
|