Update Neovim Dependencies #51
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 Dependencies | |
on: | |
schedule: | |
- cron: "0 16 * * *" # Runs at 00:00 UTC every day | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update-deps: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.PAT }} | |
fetch-depth: 0 | |
- name: Setup Neovim | |
uses: rhysd/action-setup-vim@v1 | |
with: | |
neovim: true | |
version: stable | |
- name: Install lazy.nvim | |
run: | | |
mkdir -p ~/.local/share/nvim/site/pack/lazy/start | |
git clone --filter=blob:none https://github.com/folke/lazy.nvim.git --branch=stable ~/.local/share/nvim/site/pack/lazy/start/lazy.nvim | |
- name: Set up Neovim configuration | |
run: | | |
mkdir -p ~/.config | |
ln -s $GITHUB_WORKSPACE ~/.config/nvim | |
- name: Update dependencies | |
run: | | |
nvim --headless "+Lazy! sync" +qa | |
nvim --headless "+Lazy! sync" +qa # Run twice to ensure all dependencies are updated due to AstroNvim | |
- name: Check for changes | |
id: git-check | |
run: | | |
git diff --exit-code || echo "changes=true" >> $GITHUB_OUTPUT | |
- name: Check for changes and commit | |
id: commit | |
uses: actions/github-script@v7 | |
env: | |
GIT_NAME: ${{ secrets.GIT_NAME }} | |
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | |
GITHUB_TOKEN: ${{ secrets.PAT }} | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const { execSync } = require('child_process'); | |
// Check if there are any changes | |
try { | |
execSync('git diff --exit-code'); | |
console.log('No changes detected'); | |
return false; | |
} catch (error) { | |
console.log('Changes detected'); | |
} | |
// Set up git configuration using secrets | |
execSync(`git config user.name "${process.env.GIT_NAME}"`); | |
execSync(`git config user.email "${process.env.GIT_EMAIL}"`); | |
// Stage changes | |
execSync('git add .'); | |
// Commit changes | |
const commitMessage = 'chore(deps): Auto-update Neovim dependencies'; | |
execSync(`git commit -m "${commitMessage}"`); | |
// Push changes | |
execSync('git push'); | |
console.log('Changes pushed successfully'); | |
return true; | |
- name: Trigger dependent workflow | |
if: success() | |
uses: peter-evans/repository-dispatch@v3 | |
with: | |
token: ${{ secrets.PAT }} | |
repository: rick-yao/dotfiles | |
event-type: neovim-deps-updated |