2.home-manager/.github/workflows/update-maintainers.yml
Austin Horstman 212f4a4fb2 ci: update-maintainers fetch nixpkgs from flake.lock rev
We need a nixpkgs on NIX_PATH. Right now we have been using the latest
from channel. But, we can actually just fetch the nixpkgs from our
flake.lock by parsing the flake.lock.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-07-01 23:03:57 -05:00

137 lines
5.7 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Update maintainers list
on:
schedule:
# Update every Monday at 9 AM UTC
- cron: "0 9 * * 1"
workflow_dispatch:
inputs:
create_pr:
description: 'Create PR even if no changes'
required: false
default: false
type: boolean
jobs:
update-maintainers:
runs-on: ubuntu-latest
if: github.event_name != 'schedule' || github.repository_owner == 'nix-community'
steps:
- name: Create GitHub App token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.CI_APP_ID }}
private-key: ${{ secrets.CI_APP_PRIVATE_KEY }}
- name: Get GitHub App user info
id: user-info
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
slug: ${{ steps.app-token.outputs.app-slug }}
run: |
name="$slug[bot]"
id=$(gh api "/users/$name" --jq .id)
{
echo "id=$id"
echo "name=$name"
echo "email=$id+$name@users.noreply.github.com"
} >> "$GITHUB_OUTPUT"
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Get Nixpkgs revision from flake.lock
id: get-nixpkgs
run: |
echo "rev=$(jq -r '.nodes.nixpkgs.locked.rev' flake.lock)" >> "$GITHUB_OUTPUT"
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=https://github.com/NixOS/nixpkgs/archive/${{ steps.get-nixpkgs.outputs.rev }}.tar.gz
- name: Setup Git
run: |
git config user.name "${{ steps.user-info.outputs.name }}"
git config user.email "${{ steps.user-info.outputs.email }}"
- name: Generate updated maintainers list
run: |
echo "📋 Generating updated all-maintainers.nix..."
./lib/python/generate-all-maintainers.py
- name: Check for changes
id: check-changes
run: "if git diff --quiet all-maintainers.nix; then\n echo \"No changes to all-maintainers.nix\"\n echo \"has_changes=false\" >> \"$GITHUB_OUTPUT\"\nelse\n echo \"Changes detected in all-maintainers.nix\"\n echo \"has_changes=true\" >> \"$GITHUB_OUTPUT\"\n \n # Get change statistics\n added=$(git diff --numstat all-maintainers.nix | cut -f1)\n removed=$(git diff --numstat all-maintainers.nix | cut -f2)\n echo \"changes_summary=+$added -$removed lines\" >> \"$GITHUB_OUTPUT\"\nfi\n"
- name: Validate generated file
if: steps.check-changes.outputs.has_changes == 'true'
run: |
echo "🔍 Validating generated all-maintainers.nix..."
if nix eval --file ./all-maintainers.nix --json > /dev/null; then
echo "✅ Generated file has valid Nix syntax"
else
echo "❌ Generated file has invalid Nix syntax"
exit 1
fi
- name: Create Pull Request
if: steps.check-changes.outputs.has_changes == 'true' || github.event.inputs.create_pr == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
# Create a new branch for the update
branch_name="maintainers/update-$(date +%Y%m%d%H%M%S)"
git checkout -b "$branch_name"
# Commit the changes
git add all-maintainers.nix
git commit -m "maintainers: update all-maintainers.nix
Automated update of the master maintainers list combining:
- Home Manager specific maintainers from modules/lib/maintainers.nix
- Nixpkgs maintainers referenced in Home Manager modules
Changes: ${{ steps.check-changes.outputs.changes_summary || 'No content changes' }}
Generated by: lib/python/generate-all-maintainers.py"
# Push the branch
git push origin "$branch_name"
# Create the pull request
gh pr create \
--title "maintainers: update all-maintainers.nix" \
--body "$(cat <<'EOF'
## 📋 Summary
This PR updates the master maintainers list (`all-maintainers.nix`) which combines:
- **Home Manager specific maintainers** from `modules/lib/maintainers.nix`
- **Nixpkgs maintainers** referenced in Home Manager modules
## 🔄 Changes
**Statistics:** ${{ steps.check-changes.outputs.changes_summary || 'No content changes (format/comment updates only)' }}
The updated list includes all maintainers needed for review assignments across the Home Manager project.
## 🤖 Automation
- **Generated by:** `lib/python/generate-all-maintainers.sh`
- **Trigger:** ${{ github.event_name == 'schedule' && 'Scheduled weekly update' || 'Manual workflow dispatch' }}
- **Validation:** File syntax verified with `nix eval`
## 📚 Usage
This file can be imported and used for maintainer lookups:
```nix
let allMaintainers = import ./all-maintainers.nix; in
# Access any maintainer by name: allMaintainers.username
```
---
🤖 *This PR was automatically created by the [update-maintainers workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})*
EOF
)" \
--label "dependencies" \
--label "maintainers"
- name: Summary
run: |
if [[ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]]; then
echo "✅ Successfully created PR with maintainer updates"
echo "📊 Changes: ${{ steps.check-changes.outputs.changes_summary }}"
else
echo " No changes detected - maintainers list is up to date"
fi