2022-03-18 08:46:35 -07:00
|
|
|
# Autogenerate the API docs on new commit to important branches
|
2022-03-25 11:57:59 -07:00
|
|
|
# Also work as a check for PR's to not forget committing their doc changes
|
2022-03-18 08:46:35 -07:00
|
|
|
# called from api-docs-check.yml
|
2021-05-31 19:20:08 -07:00
|
|
|
name: Autogenerate API docs
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
paths:
|
|
|
|
- 'src/nvim/api/*.[ch]'
|
|
|
|
- 'runtime/lua/**.lua'
|
2022-03-26 05:22:03 -07:00
|
|
|
- 'runtime/doc/**'
|
2021-05-31 19:20:08 -07:00
|
|
|
branches:
|
|
|
|
- 'master'
|
|
|
|
- 'release-[0-9]+.[0-9]+'
|
|
|
|
workflow_dispatch:
|
2022-03-18 08:46:35 -07:00
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
check_only:
|
|
|
|
type: boolean
|
|
|
|
default: false
|
|
|
|
required: false
|
2021-05-31 19:20:08 -07:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
regen-api-docs:
|
2022-05-24 03:21:17 -07:00
|
|
|
runs-on: ubuntu-22.04
|
2021-05-31 19:20:08 -07:00
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
pull-requests: write
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
steps:
|
2022-05-20 20:45:10 -07:00
|
|
|
- uses: actions/checkout@v3
|
2021-05-31 19:20:08 -07:00
|
|
|
with:
|
2022-05-24 03:29:12 -07:00
|
|
|
# Fetch depth 0 is required if called through workflow_call. In order
|
|
|
|
# to create a PR we need to access other branches, which requires a
|
|
|
|
# full clone.
|
2021-05-31 19:20:08 -07:00
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
sudo apt-get update
|
2022-05-24 03:21:17 -07:00
|
|
|
sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y doxygen python3 python3-msgpack luajit
|
2021-05-31 19:20:08 -07:00
|
|
|
|
|
|
|
- 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 $?)
|
|
|
|
|
2022-03-25 11:57:59 -07:00
|
|
|
- name: FAIL, PR has not committed doc changes
|
2022-03-18 08:46:35 -07:00
|
|
|
if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 && inputs.check_only }}
|
|
|
|
run: |
|
|
|
|
echo "Job failed, run ./scripts/gen_vimdoc.py and commit your doc changes"
|
2022-03-26 05:22:03 -07:00
|
|
|
echo "The doc generation produces the following changes:"
|
|
|
|
git --no-pager diff
|
2022-03-18 08:46:35 -07:00
|
|
|
exit 1
|
|
|
|
|
2021-05-31 19:20:08 -07:00
|
|
|
- name: Automatic PR
|
2022-03-21 20:40:24 -07:00
|
|
|
if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 && !inputs.check_only }}
|
2021-05-31 19:20:08 -07:00
|
|
|
run: |
|
|
|
|
git add -u
|
2022-01-15 19:06:18 -07:00
|
|
|
git commit -m 'docs: regenerate [skip ci]'
|
2021-05-31 19:20:08 -07:00
|
|
|
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${DOC_BRANCH}
|
2022-01-17 11:32:51 -07:00
|
|
|
gh pr create --draft --fill --base ${GITHUB_REF#refs/heads/} --head ${DOC_BRANCH} || true
|