Update Neovim Plugins #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Neovim Plugins | |
on: | |
schedule: | |
# Run Daily | |
- cron: "0 23 * * *" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
update: | |
name: Lazy update | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: Homebrew/actions/setup-homebrew@master | |
- name: Install Neovim | |
run: | | |
brew install nvim | |
- name: Symlink dotfiles | |
run: | | |
BASE_PATH="$(git rev-parse --show-toplevel)" | |
ln -s "$BASE_PATH/.config/nvim" "$HOME/.config/nvim" | |
- name: Run Updates | |
id: update | |
run: | | |
tmp_logs="$(mktemp)" | |
nvim --version | |
nvim --headless "+Lazy! update" +qa! | sed -r 's/\x1B\[[0-9;]*[mK]//g' | sed 's/)\[/)\n[/g' >> "${tmp_logs}" | |
updated_plugins="$(git diff .config/nvim/lazy-lock.json | awk 'NR>6 && /^\+/ { print $2 }' | cut -d'"' -f2)" | |
print_changelog() { | |
for plugin; do | |
printf "%b" "## ${plugin}\n\n" | |
plugin_changelog="$(grep "^\[${plugin}\].*log" "${tmp_logs}" | tail -n +2 | tail -r | tail -n +2 | tail -r | cut -d\| -f2- | sed -e '/^ $/d' -e 's/^ //' -e 's/^[^ ]*/- `&`/')" | |
printf "%b" "${plugin_changelog}\n\n" | |
done | |
} | |
echo "plugin_changelog<<EOF" >> $GITHUB_OUTPUT | |
print_changelog $updated_plugins >> $GITHUB_OUTPUT | |
echo "EOF" >> $GITHUB_OUTPUT | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
base: main | |
token: ${{ secrets.TOKEN }} | |
branch: lazy-update | |
commit-message: Update lazy-lock | |
title: Update lazy-lock | |
body: | | |
Updated plugins: | |
${{ steps.update.outputs.plugin_changelog }} |