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, bare-metal] container: image: nixos/nix:latest steps: - name: Checkout uses: actions/checkout@v4 - name: Configure Nix run: | mkdir -p /etc/nix echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf - name: Update flake.lock 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: Commit and open PR if: steps.changes.outputs.changed == 'true' env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | BRANCH="automated/flake-lock-$(date +%Y%m%d)" git config user.name "klaatu" git config user.email "klaatu@thehellings.com" git checkout -b "$BRANCH" git add flake.lock git commit -m "chore: update flake.lock" git push origin "$BRANCH" # Open PR via Gitea API curl -s -X POST \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ -d "{ \"title\": \"chore: update flake.lock\", \"head\": \"${BRANCH}\", \"base\": \"main\", \"body\": \"Automated weekly flake.lock update.\n\nGenerated by the update-flake-lock workflow.\" }" \ "${GITHUB_SERVER_URL%/}/api/v1/repos/${GITHUB_REPOSITORY}/pulls"