From e8beb7f2a932ffa6d5330829c26f4b9c3c152b75 Mon Sep 17 00:00:00 2001 From: klaatu Date: Sat, 4 Apr 2026 06:18:12 +0000 Subject: [PATCH] feat: add update-flake-lock workflow --- .gitea/workflows/update-flake-lock.yaml | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .gitea/workflows/update-flake-lock.yaml diff --git a/.gitea/workflows/update-flake-lock.yaml b/.gitea/workflows/update-flake-lock.yaml new file mode 100644 index 0000000..cb2535e --- /dev/null +++ b/.gitea/workflows/update-flake-lock.yaml @@ -0,0 +1,51 @@ +name: Update flake.lock + +on: + schedule: + - cron: "0 0 * * 0" # Every Sunday at midnight UTC + workflow_dispatch: + +jobs: + update-flake-lock: + runs-on: [self-hosted, nix] + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Update flake.lock + run: nix flake update + + - name: Create PR if changed + env: + GITEA_TOKEN: ${{ secrets.KLAATU_TOKEN }} + GITEA_URL: https://src.thehellings.com + REPO: greg/nixos + run: | + if git diff --quiet flake.lock; then + echo "flake.lock unchanged, nothing to do" + exit 0 + fi + + BRANCH="auto/update-flake-lock-$(date +%Y%m%d)" + git config user.email "klaatu@thehellings.com" + git config user.name "klaatu" + git checkout -b "$BRANCH" + git add flake.lock + git commit -m "chore: update flake.lock $(date +%Y-%m-%d)" + + # Push branch using token auth + git remote set-url origin "https://klaatu:${GITEA_TOKEN}@${GITEA_URL#https://}/${REPO}.git" + git push origin "$BRANCH" + + # Create PR via Gitea API + curl -s -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_URL}/api/v1/repos/${REPO}/pulls" \ + -d "{ + \"title\": \"chore: update flake.lock $(date +%Y-%m-%d)\", + \"head\": \"$BRANCH\", + \"base\": \"main\", + \"body\": \"Automated weekly flake.lock update.\\n\\nGenerated by Gitea Actions.\", + \"assignees\": [\"greg\"] + }"