Skip to content

neovim-deps-updated #86

neovim-deps-updated

neovim-deps-updated #86

Workflow file for this run

name: Nix Flake and Submodule Update
on:
# schedule:
# - cron: "0 17 * * *"
workflow_dispatch:
repository_dispatch:
types: [neovim-deps-updated]
permissions:
contents: write
pull-requests: write
env:
PR_BRANCH: "automated-flake-and-submodule-update"
PR_LABEL: "automated-update"
jobs:
update-flake-and-submodule:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "recursive"
fetch-depth: 0
- name: Debug Info
run: |
echo "GitHub event name: ${{ github.event_name }}"
echo "Update submodule: ${{ github.event.inputs.update_submodule }}"
echo "Update flake: ${{ github.event.inputs.update_flake }}"
echo "Create PR: ${{ github.event.inputs.create_pr }}"
- name: Check for existing PR
id: check_pr
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log("Checking for existing PR");
const prs = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${process.env.PR_BRANCH}`
});
console.log(`Found ${prs.data.length} potential PRs`);
for (const pr of prs.data) {
const labels = pr.labels.map(label => label.name);
console.log(`PR #${pr.number} labels: ${labels.join(', ')}`);
if (labels.includes(process.env.PR_LABEL)) {
console.log(`Existing automated PR found: #${pr.number}`);
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
state: 'closed'
});
console.log(`Closed PR #${pr.number}`);
break;
}
}
- name: Update submodule
run: |
echo "Updating submodule"
git config user.name github-actions
git config user.email github-actions@github.com
git checkout -b ${{ env.PR_BRANCH }}
git submodule update --remote config/nvim
git add config/nvim
git diff --cached --exit-code || (git commit -m "chore(deps): update nvim submodule" && echo "Submodule changes committed")
echo "Submodule update complete"
- name: Install Nix
uses: cachix/install-nix-action@v27
- name: Update flake.lock
run: |
echo "Updating flake.lock"
nix flake update --accept-flake-config
git add flake.lock
git diff --cached --exit-code || (git commit -m "chore(deps): update flake.lock" && echo "Flake.lock changes committed")
echo "Flake.lock update complete"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore(deps): update flake.lock and astro nvim submodule"
title: "chore(deps): update flake.lock and astro nvim submodule"
body: |
This is an automated PR to update `flake.lock` to the latest versions and update the 'config/nvim/astro' submodule.
Please review the changes and merge if everything looks good.
branch: ${{ env.PR_BRANCH }}
base: "main"
labels: |
${{ env.PR_LABEL }}
- name: PR Creation Result
run: |
echo "PR creation step completed"
echo "If no PR was created, check if there were any changes to commit"