Add Forgejo runner and check update action

This commit is contained in:
pazpi 2025-12-03 17:20:23 +01:00
parent ce9f9d17cb
commit ed796a19fe
10 changed files with 254 additions and 0 deletions

View file

@ -0,0 +1,72 @@
name: Weekly Flake Update
on:
schedule:
# Every Friday at 22:00 UTC
- cron: '0 22 * * 5'
workflow_dispatch: {}
jobs:
update:
runs-on: nix
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "Flake Update Bot"
git config user.email "bot@noreply.local"
- name: Update flake inputs
run: nix flake update
- name: Check for changes
id: changes
run: |
if git diff --quiet flake.lock; then
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "changed=true" >> $GITHUB_OUTPUT
fi
- name: Build all hosts
if: steps.changes.outputs.changed == 'true'
run: |
nix develop -c colmena build
- name: Create branch and commit
if: steps.changes.outputs.changed == 'true'
run: |
BRANCH_NAME="auto-update/$(date +%Y-%m-%d)"
git checkout -b "$BRANCH_NAME"
git add flake.lock
git commit -m "chore: update flake inputs $(date +%Y-%m-%d)"
git push origin "$BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
id: branch
- name: Create Pull Request
if: steps.changes.outputs.changed == 'true'
env:
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
run: |
curl -X POST \
-H "Authorization: token $FORGEJO_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "chore: weekly flake update",
"body": "Automated flake update from CI.\n\nThis PR updates all flake inputs and has been verified to build successfully.\n\nGenerated on: '"$(date -Iseconds)"'",
"head": "'"${{ steps.branch.outputs.branch_name }}"'",
"base": "master"
}' \
"${{ github.server_url }}/api/v1/repos/${{ github.repository }}/pulls"
- name: Cleanup
if: always()
run: |
nix-collect-garbage -d
rm -rf result .direnv