aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/api-docs.yml
blob: ee72cf5f01ba6113704afab95a0de513f3f7cde9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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:

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: Automatic PR
        if: ${{ steps.docs.outputs.UPDATED_DOCS != 0 }}
        run: |
          git add -u
          git commit -m 'docs: regenerate'
          git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${DOC_BRANCH}
          gh pr create --fill --base ${GITHUB_REF#refs/heads/} --head ${DOC_BRANCH} || true