api-docs.yml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # Autogenerate the API docs on new commit to important branches
  2. # Also work as a check for PR's to not forget committing their doc changes
  3. # called from api-docs-check.yml
  4. name: Autogenerate API docs
  5. on:
  6. push:
  7. paths:
  8. - 'src/nvim/api/*.[ch]'
  9. - 'runtime/lua/**.lua'
  10. - 'runtime/doc/**'
  11. branches:
  12. - 'master'
  13. - 'release-[0-9]+.[0-9]+'
  14. workflow_dispatch:
  15. workflow_call:
  16. inputs:
  17. check_only:
  18. type: boolean
  19. default: false
  20. required: false
  21. jobs:
  22. regen-api-docs:
  23. runs-on: ubuntu-20.04
  24. permissions:
  25. contents: write
  26. pull-requests: write
  27. env:
  28. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  29. steps:
  30. - uses: actions/checkout@v2
  31. with:
  32. fetch-depth: 0
  33. - name: Install dependencies
  34. run: |
  35. sudo apt-get update
  36. sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y python3 luajit
  37. conda install -c conda-forge doxygen=1.9.2 msgpack-python
  38. echo "$CONDA/bin" >> $GITHUB_PATH
  39. - name: Setup git config
  40. run: |
  41. git config --global user.name 'marvim'
  42. git config --global user.email 'marvim@users.noreply.github.com'
  43. - run: printf 'DOC_BRANCH=marvim/api-doc-update/%s\n' ${GITHUB_REF#refs/heads/} >> $GITHUB_ENV
  44. - name: Generate docs
  45. id: docs
  46. run: |
  47. git checkout -b ${DOC_BRANCH}
  48. python3 scripts/gen_vimdoc.py
  49. printf '::set-output name=UPDATED_DOCS::%s\n' $([ -z "$(git diff)" ]; echo $?)
  50. - name: FAIL, PR has not committed doc changes
  51. if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 && inputs.check_only }}
  52. run: |
  53. echo "Job failed, run ./scripts/gen_vimdoc.py and commit your doc changes"
  54. echo "The doc generation produces the following changes:"
  55. git --no-pager diff
  56. exit 1
  57. - name: Automatic PR
  58. if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 && !inputs.check_only }}
  59. run: |
  60. git add -u
  61. git commit -m 'docs: regenerate [skip ci]'
  62. git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${DOC_BRANCH}
  63. gh pr create --draft --fill --base ${GITHUB_REF#refs/heads/} --head ${DOC_BRANCH} || true