1
0
mirror of synced 2026-01-15 15:01:34 -05:00
Files
docs/.github/workflows/openapi-decorate.yml
2023-01-13 22:34:49 +00:00

89 lines
3.9 KiB
YAML

name: Sync OpenAPI schema
# **What it does**: Once a day, this workflow syncs the dereferenced files from github/rest-api-description and creates a pull request if there are updates to any of the static files we generate from the OpenAPI.
# **Why we have it**: So we can consume OpenAPI changes.
# **Who does it impact**: Anyone making OpenAPI changes in `github/github`, and wanting to get them published on the docs site.
on:
workflow_dispatch:
schedule:
- cron: '20 16 * * *' # Run every day at 16:20 UTC / 8:20 PST
permissions:
contents: write
pull-requests: write
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
generate-decorated-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: Label pull requests with 'github-openapi-bot'
uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90
with:
add-labels: 'github-openapi-bot'
- name: Checkout repository code
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
# Check out a nested repository inside of previous checkout
- name: Checkout rest-api-description repo
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
# By default, only the most recent commit of the `main` branch
# will be checked out
repository: github/rest-api-description
path: rest-api-description
- name: Copy dereferenced OpenAPI files
id: rest-api-description
run: |
mkdir ./lib/rest/static/dereferenced
find rest-api-description/descriptions-next -type f -name "*.deref.json" -exec sh -c 'cp $1 ./lib/rest/static/dereferenced' sh {} \;
cd rest-api-description
OPENAPI_COMMIT_SHA=$(git rev-parse HEAD)
echo "OPENAPI_COMMIT_SHA=$OPENAPI_COMMIT_SHA" >> $GITHUB_OUTPUT
echo "Copied files from github/rest-api-description repo. Commit SHA: $OPENAPI_COMMIT_SHA"
- uses: ./.github/actions/node-npm-setup
- name: Decorate the dereferenced OpenAPI schemas
run: script/rest/update-files.js --decorate-only --open-source
# This action performs the diff and if no files have been change
# the action exits silently.
- name: Create pull request
id: create-pull-request
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
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 }}
add-paths: |
- lib/rest/static/apps
- lib/rest/static/decorated
- lib/webhooks/static/decorated
- lib/redirects/static/client-side-rest-api-redirects.json
commit-message: 'Add decorated OpenAPI schema files'
title: Update OpenAPI Description
body: |
'👋 humans. This PR updates the OpenAPI description with the latest changes. (Synced from github/rest-api-description@${{ steps.rest-api-description.outputs.OPENAPI_COMMIT_SHA }})
If CI does not pass or other problems arise, contact #docs-engineering on slack.'
branch: openapi-update-${{ steps.rest-api-description.outputs.OPENAPI_COMMIT_SHA }}