aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/vim_patches.yml
blob: 05af39f19c38534225be3f169703cc6e76c3a54e (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
54
55
name: vim-patches
on:
  schedule:
    - cron: '3 3 * * *'
  workflow_dispatch:

jobs:
  update-vim-patches:
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    env:
      VIM_SOURCE_DIR: ${{ github.workspace }}/vim-src
      VERSION_BRANCH: marvim/ci-version-update
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/checkout@v4
        with:
          repository: vim/vim
          path: ${{ env.VIM_SOURCE_DIR }}
          fetch-depth: 0

      - run: sudo apt-get install libfuse2

      - run: |
          gh release download -R neovim/neovim -p nvim-linux-x86_64.appimage
          chmod a+x nvim-linux-x86_64.appimage
          mkdir -p $HOME/.local/bin
          mv nvim-linux-x86_64.appimage $HOME/.local/bin/nvim
          printf '%s\n' "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Set up 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 -l scripts/vimpatch.lua
          printf 'NEW_PATCHES=%s\n' $([ -z "$(git diff)" ]; echo $?) >> $GITHUB_OUTPUT

      - name: Automatic PR
        if: ${{ steps.update-version.outputs.NEW_PATCHES != 0 }}
        run: |
          git add -u
          git commit -m 'docs: update version.c'
          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