diff --git a/.github/workflows/update-flake.yml b/.github/workflows/update-flake.yml index 8565e77b59ecf6dc71b9f3839ae6fe0981ea4037..f2b544dd6ffac8d94bb5c9c6e66ca7ac0606c50e 100644 --- a/.github/workflows/update-flake.yml +++ b/.github/workflows/update-flake.yml @@ -8,6 +8,7 @@ on: permissions: contents: write + pull-requests: write jobs: update: @@ -20,14 +21,18 @@ jobs: - name: Update flake.lock run: nix flake update - - name: Commit and push changes + - name: Create Pull Request env: GH_TOKEN: ${{ github.token }} run: | git diff --quiet flake.lock && exit 0 + BRANCH="chore/update-flake-lock" git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add . - git commit -m "chore: update flake.lock (#228)" - git remote set-url origin https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}.git - git push origin HEAD:${GITHUB_REF} + git checkout -b "$BRANCH" + git add flake.lock + git commit -m "chore: update flake.lock" + git push -f origin "$BRANCH" + if ! gh pr list --head "$BRANCH" --state open | grep -q .; then + gh pr create --title "chore: update flake.lock" --body "Automated flake.lock update." --base master + fi