From df52d021679a9041d80478b5131a4c519a84d9b6 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 21 Mar 2024 01:28:09 +0100 Subject: [PATCH 1/5] Give more information in automated update PRs At least the output from `npins update nixpkgs` --- .github/workflows/update.yml | 6 +++--- default.nix | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 56e42fa..c07ad57 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -14,8 +14,8 @@ jobs: - name: update run: | - nix-build -A pkgs.npins - result/bin/npins update nixpkgs + nix-build -A autoPrUpdate + result/bin/auto-pr-update > body - name: Create Pull Request uses: peter-evans/create-pull-request@v6 @@ -23,4 +23,4 @@ jobs: commit-message: "Automated Nixpkgs update" branch: auto-nixpkgs-update title: "Automated Nixpkgs update" - body: "Update the pinned Nixpkgs automatically" + body-path: body diff --git a/default.nix b/default.nix index 451d134..ff071b7 100644 --- a/default.nix +++ b/default.nix @@ -53,6 +53,28 @@ build // { ]; }; + # Run regularly by CI and turned into a PR + autoPrUpdate = pkgs.writeShellApplication { + name = "auto-pr-update"; + runtimeInputs = with pkgs; [ + npins + ]; + text = + let + commands = [ + "npins update nixpkgs" + ]; + in + '' + echo "Run automated updates" + '' + + pkgs.lib.concatMapStrings (command: '' + echo -e '
${command}\n\n```' + ${command} 2>&1 + echo -e '```\n
' + '') commands; + }; + # Tests the tool on the pinned Nixpkgs tree, this is a good sanity check checks.nixpkgs = pkgs.runCommand "test-nixpkgs-check-by-name" { nativeBuildInputs = [ From 8d1f3d121ab12f72a93c5c4bca0f09479a5d6e94 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 21 Mar 2024 01:30:39 +0100 Subject: [PATCH 2/5] Don't limit automated npins update to just nixpkgs No reason to --- .github/workflows/update.yml | 6 +++--- default.nix | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index c07ad57..635e862 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -20,7 +20,7 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: - commit-message: "Automated Nixpkgs update" - branch: auto-nixpkgs-update - title: "Automated Nixpkgs update" + commit-message: "Automated update" + branch: auto-update + title: "Automated update" body-path: body diff --git a/default.nix b/default.nix index ff071b7..3d62b9c 100644 --- a/default.nix +++ b/default.nix @@ -62,7 +62,7 @@ build // { text = let commands = [ - "npins update nixpkgs" + "npins update" ]; in '' From 80f75640820afd6627a8f13637ac423a663e8a42 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 21 Mar 2024 01:31:20 +0100 Subject: [PATCH 3/5] Also do automated cargo update --- default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/default.nix b/default.nix index 3d62b9c..5e9bef6 100644 --- a/default.nix +++ b/default.nix @@ -58,11 +58,13 @@ build // { name = "auto-pr-update"; runtimeInputs = with pkgs; [ npins + cargo ]; text = let commands = [ "npins update" + "cargo update" ]; in '' From a7593f844e2d7f4e62339a536c15a719c63d9924 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 21 Mar 2024 01:31:42 +0100 Subject: [PATCH 4/5] Do automated PRs from a fork to trigger CI --- .github/workflows/update.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 635e862..fdc1dd8 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -20,6 +20,11 @@ jobs: - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: + # To trigger CI for automated PRs, we use a separate machine account + # See https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs + # and https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#push-pull-request-branches-to-a-fork + token: ${{ secrets.MACHINE_USER_PAT }} + push-to-fork: infinixbot/nixpkgs-check-by-name commit-message: "Automated update" branch: auto-update title: "Automated update" From 157ab23d026a6e2a95f7f26362f0f536b6619b23 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 21 Mar 2024 01:38:54 +0100 Subject: [PATCH 5/5] Set automated PR committer and author to the machine account --- .github/workflows/update.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index fdc1dd8..3057317 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -25,6 +25,8 @@ jobs: # and https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#push-pull-request-branches-to-a-fork token: ${{ secrets.MACHINE_USER_PAT }} push-to-fork: infinixbot/nixpkgs-check-by-name + committer: infinixbot + author: infinixbot commit-message: "Automated update" branch: auto-update title: "Automated update"