neovim/.github/workflows/vim-patches.yml
James McCoy 66076e5e1b
ci: create automated PRs as draft PRs
GH workflows aren't allowed to trigger other GH workflows.  Since
commitlint is a required check now, we need something manual to happen
for it to run on vim-patch/api-doc PRs.

Creating these PRs as drafts and then marking them as "ready to review"
when we want to merge them will provide the manual trigger to run
commitlint.

[skip ci]
2022-01-17 13:36:01 -05:00

53 lines
1.7 KiB
YAML

name: vim-patches
on:
schedule:
- cron: '3 3 * * *'
jobs:
update-vim-patches:
runs-on: ubuntu-20.04
permissions:
contents: write
pull-requests: write
env:
VIM_SOURCE_DIR: ${{ format('{0}/vim-src', github.workspace) }}
VERSION_BRANCH: marvim/ci-version-update
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/checkout@v2
with:
repository: vim/vim
path: ${{ env.VIM_SOURCE_DIR }}
fetch-depth: 0
- run: |
gh release download -R neovim/neovim -p nvim.appimage
chmod a+x nvim.appimage
mkdir -p $HOME/.local/bin
mv nvim.appimage $HOME/.local/bin/nvim
printf '%s\n' "$HOME/.local/bin" >> $GITHUB_PATH
- name: Setup git config
run: |
git config --global user.name 'marvim'
git config --global user.email 'marvim@users.noreply.github.com'
- name: Update src/version.c
id: update-version
run: |
git checkout -b ${VERSION_BRANCH}
nvim -i NONE -u NONE --headless +'luafile scripts/vimpatch.lua' +q
printf '::set-output name=NEW_PATCHES::%s\n' $([ -z "$(git diff)" ]; echo $?)
- name: Automatic PR
if: ${{ steps.update-version.outputs.NEW_PATCHES != 0 }}
run: |
git add -u
git commit -m 'version.c: update [skip ci]'
git push --force https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} ${VERSION_BRANCH}
gh pr create --draft --fill --label vim-patch --base ${GITHUB_REF#refs/heads/} --head ${VERSION_BRANCH} || true