neovim/.github/workflows/api-docs.yml
Javier López 9191401025 ci(docs): add a check for PR's to commit their doc changes
Repurpose the api-docs workflow to also run in all PR's but work only as
a check, if the changes in the PR introduce doc changes that are not
committed fail.

[skip ci]
2022-03-18 13:29:55 -05:00

69 lines
2.1 KiB
YAML

# Autogenerate the API docs on new commit to important branches
# Also work as a check for PR's to not forget commiting their doc changes
# called from api-docs-check.yml
name: Autogenerate API docs
on:
push:
paths:
- 'src/nvim/api/*.[ch]'
- 'src/nvim/**.lua'
- 'runtime/lua/**.lua'
branches:
- 'master'
- 'release-[0-9]+.[0-9]+'
workflow_dispatch:
workflow_call:
inputs:
check_only:
type: boolean
default: false
required: false
jobs:
regen-api-docs:
runs-on: ubuntu-20.04
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install dependencies
run: |
sudo apt-get update
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y python3 luajit
conda install -c conda-forge doxygen=1.9.2 msgpack-python
echo "$CONDA/bin" >> $GITHUB_PATH
- name: Setup git config
run: |
git config --global user.name 'marvim'
git config --global user.email 'marvim@users.noreply.github.com'
- run: printf 'DOC_BRANCH=marvim/api-doc-update/%s\n' ${GITHUB_REF#refs/heads/} >> $GITHUB_ENV
- name: Generate docs
id: docs
run: |
git checkout -b ${DOC_BRANCH}
python3 scripts/gen_vimdoc.py
printf '::set-output name=UPDATED_DOCS::%s\n' $([ -z "$(git diff)" ]; echo $?)
- name: FAIL, PR has not commited doc changes
if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 && inputs.check_only }}
run: |
echo "Job failed, run ./scripts/gen_vimdoc.py and commit your doc changes"
exit 1
- name: Automatic PR
if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 }}
run: |
git add -u
git commit -m 'docs: regenerate [skip ci]'
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${DOC_BRANCH}
gh pr create --draft --fill --base ${GITHUB_REF#refs/heads/} --head ${DOC_BRANCH} || true