mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
touchpr: init
Useful to force push in a PR so as to trigger github actions, as with flake-lock-update action created PRs.
This commit is contained in:
parent
78e101f434
commit
db392e4917
7 changed files with 182 additions and 19 deletions
128
flake.lock
generated
128
flake.lock
generated
|
|
@ -32,7 +32,7 @@
|
|||
"ragenix",
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems_7"
|
||||
"systems": "systems_8"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1707830867,
|
||||
|
|
@ -455,6 +455,24 @@
|
|||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"inputs": {
|
||||
"systems": "systems_5"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1681202837,
|
||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_5": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
|
|
@ -469,9 +487,9 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_5": {
|
||||
"flake-utils_6": {
|
||||
"inputs": {
|
||||
"systems": "systems_5"
|
||||
"systems": "systems_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
|
|
@ -487,9 +505,9 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_6": {
|
||||
"flake-utils_7": {
|
||||
"inputs": {
|
||||
"systems": "systems_8"
|
||||
"systems": "systems_9"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
|
|
@ -654,7 +672,7 @@
|
|||
"flake-parts": "flake-parts_5",
|
||||
"flake-schemas": "flake-schemas_2",
|
||||
"libgit2": "libgit2",
|
||||
"nixpkgs": "nixpkgs_5",
|
||||
"nixpkgs": "nixpkgs_6",
|
||||
"nixpkgs-23-11": "nixpkgs-23-11",
|
||||
"nixpkgs-regression": "nixpkgs-regression",
|
||||
"pre-commit-hooks": "pre-commit-hooks"
|
||||
|
|
@ -914,6 +932,20 @@
|
|||
}
|
||||
},
|
||||
"nixpkgs_5": {
|
||||
"locked": {
|
||||
"lastModified": 1701436327,
|
||||
"narHash": "sha256-tRHbnoNI8SIM5O5xuxOmtSLnswEByzmnQcGGyNRjxsE=",
|
||||
"rev": "91050ea1e57e50388fa87a3302ba12d188ef723a",
|
||||
"revCount": 555097,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.1.555097%2Brev-91050ea1e57e50388fa87a3302ba12d188ef723a/018c3450-2363-7c34-883b-4ba70b1eb7ae/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/NixOS/nixpkgs/0.1.%2A.tar.gz"
|
||||
}
|
||||
},
|
||||
"nixpkgs_6": {
|
||||
"locked": {
|
||||
"lastModified": 1717432640,
|
||||
"narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=",
|
||||
|
|
@ -929,7 +961,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_6": {
|
||||
"nixpkgs_7": {
|
||||
"locked": {
|
||||
"lastModified": 1722415718,
|
||||
"narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=",
|
||||
|
|
@ -945,7 +977,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_7": {
|
||||
"nixpkgs_8": {
|
||||
"locked": {
|
||||
"lastModified": 1708655239,
|
||||
"narHash": "sha256-ZrP/yACUvDB+zbqYJsln4iwotbH6CTZiTkANJ0AgDv4=",
|
||||
|
|
@ -961,7 +993,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_8": {
|
||||
"nixpkgs_9": {
|
||||
"locked": {
|
||||
"lastModified": 1680945546,
|
||||
"narHash": "sha256-8FuaH5t/aVi/pR1XxnF0qi4WwMYC+YxlfdsA0V+TEuQ=",
|
||||
|
|
@ -1004,6 +1036,26 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nuenv": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_5",
|
||||
"rust-overlay": "rust-overlay_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1720763591,
|
||||
"narHash": "sha256-h8KQjMTu8upvXNga3PPTN9qpS1zyNaH/O+ltzsggzUk=",
|
||||
"owner": "hallettj",
|
||||
"repo": "nuenv",
|
||||
"rev": "f88dd67329173ab0f1d30d3b01768d9485500ad2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hallettj",
|
||||
"ref": "writeShellApplication",
|
||||
"repo": "nuenv",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"omnix": {
|
||||
"inputs": {
|
||||
"cargo-doc-live": "cargo-doc-live_2",
|
||||
|
|
@ -1011,10 +1063,10 @@
|
|||
"flake-parts": "flake-parts_4",
|
||||
"flake-schemas": "flake-schemas",
|
||||
"nix": "nix",
|
||||
"nixpkgs": "nixpkgs_6",
|
||||
"nixpkgs": "nixpkgs_7",
|
||||
"process-compose-flake": "process-compose-flake_2",
|
||||
"rust-flake": "rust-flake_2",
|
||||
"systems": "systems_6",
|
||||
"systems": "systems_7",
|
||||
"treefmt-nix": "treefmt-nix_3"
|
||||
},
|
||||
"locked": {
|
||||
|
|
@ -1037,7 +1089,7 @@
|
|||
"omnix",
|
||||
"nix"
|
||||
],
|
||||
"flake-utils": "flake-utils_4",
|
||||
"flake-utils": "flake-utils_5",
|
||||
"gitignore": [
|
||||
"omnix",
|
||||
"nix"
|
||||
|
|
@ -1101,9 +1153,9 @@
|
|||
"inputs": {
|
||||
"agenix": "agenix",
|
||||
"crane": "crane_3",
|
||||
"flake-utils": "flake-utils_6",
|
||||
"nixpkgs": "nixpkgs_7",
|
||||
"rust-overlay": "rust-overlay_3"
|
||||
"flake-utils": "flake-utils_7",
|
||||
"nixpkgs": "nixpkgs_8",
|
||||
"rust-overlay": "rust-overlay_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1718869541,
|
||||
|
|
@ -1133,6 +1185,7 @@
|
|||
"nixos-vscode-server": "nixos-vscode-server",
|
||||
"nixpkgs": "nixpkgs_4",
|
||||
"nixvim": "nixvim",
|
||||
"nuenv": "nuenv",
|
||||
"omnix": "omnix",
|
||||
"ragenix": "ragenix",
|
||||
"treefmt-nix": "treefmt-nix_4"
|
||||
|
|
@ -1169,7 +1222,7 @@
|
|||
"omnix",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-overlay": "rust-overlay_2"
|
||||
"rust-overlay": "rust-overlay_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1722280942,
|
||||
|
|
@ -1206,7 +1259,29 @@
|
|||
},
|
||||
"rust-overlay_2": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_5",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixpkgs": [
|
||||
"nuenv",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1701397143,
|
||||
"narHash": "sha256-nYUJxZXwCWWVBYZXPgRxGDuQcZRhKTtD/Jp5Jl+9EWU=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "bb71557c93cad40f5921b2342d7fd69f9e6497ab",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay_3": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_6",
|
||||
"nixpkgs": [
|
||||
"omnix",
|
||||
"rust-flake",
|
||||
|
|
@ -1227,7 +1302,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay_3": {
|
||||
"rust-overlay_4": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"ragenix",
|
||||
|
|
@ -1372,6 +1447,21 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_9": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
|
@ -1437,7 +1527,7 @@
|
|||
},
|
||||
"treefmt-nix_4": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_8"
|
||||
"nixpkgs": "nixpkgs_9"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1689243103,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
disko.url = "github:nix-community/disko";
|
||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
ragenix.url = "github:yaxitech/ragenix";
|
||||
nuenv.url = "github:hallettj/nuenv/writeShellApplication";
|
||||
|
||||
# Software inputs
|
||||
github-nix-ci.url = "github:juspay/github-nix-ci";
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
# Useful for Nix development
|
||||
om-ci-build-remote
|
||||
ci
|
||||
touchpr
|
||||
omnix
|
||||
nixpkgs-fmt
|
||||
just
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
allowUnfree = true;
|
||||
};
|
||||
overlays = [
|
||||
flake.inputs.nuenv.overlays.default
|
||||
(import ../packages/overlay.nix { inherit flake; inherit (pkgs) system; })
|
||||
];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ self: super: {
|
|||
sshuttle-via = self.callPackage ./sshuttle-via.nix { };
|
||||
om-ci-build-remote = self.callPackage (import ./om-ci-build-remote.nix { inherit (flake) inputs; }) { };
|
||||
ci = self.callPackage ./ci { };
|
||||
touchpr = self.callPackage ./touchpr { };
|
||||
# nix-health = flake.inputs.nix-browser.packages.${system}.nix-health;
|
||||
actualism-app = flake.inputs.actualism-app.packages.${system}.default;
|
||||
omnix = flake.inputs.omnix.packages.${system}.default;
|
||||
|
|
|
|||
14
packages/touchpr/default.nix
Normal file
14
packages/touchpr/default.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ nuenv, curl, jq, ... }:
|
||||
|
||||
nuenv.writeShellApplication {
|
||||
name = "touchpr";
|
||||
runtimeInputs = [ curl jq ];
|
||||
meta.description = ''
|
||||
Force push to a PR so as to trigger GitHub Actions
|
||||
'';
|
||||
text = ''
|
||||
#!/usr/bin/env nu
|
||||
|
||||
${builtins.readFile ./touchpr.nu}
|
||||
'';
|
||||
}
|
||||
55
packages/touchpr/touchpr.nu
Normal file
55
packages/touchpr/touchpr.nu
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
def main [pr_url: string] {
|
||||
let parsed = ($pr_url | parse -r 'https://github\.com/(?P<owner>[\w-]+)/(?P<repo>[\w-]+)/pull/(?P<pr_number>\d+)')
|
||||
|
||||
if ($parsed | is-empty) {
|
||||
error make {msg: "Failed to parse GitHub URL. Please ensure it's in the correct format."}
|
||||
}
|
||||
|
||||
print $"Parsed URL data: ($parsed)"
|
||||
|
||||
let owner = $parsed.owner.0
|
||||
let repo = $parsed.repo.0
|
||||
let pr_number = $parsed.pr_number.0
|
||||
|
||||
print $"Owner: ($owner)"
|
||||
print $"Repo: ($repo)"
|
||||
print $"PR Number: ($pr_number)"
|
||||
|
||||
# Construct API URL
|
||||
let api_url = $"https://api.github.com/repos/($owner)/($repo)/pulls/($pr_number)"
|
||||
|
||||
print $"Constructed API URL: ($api_url)"
|
||||
|
||||
let pr_details = (http get $api_url)
|
||||
let branch_name = $pr_details.head.ref
|
||||
let clone_url = $pr_details.head.repo.clone_url
|
||||
|
||||
# Create a temporary directory
|
||||
let temp_dir = (mktemp -d)
|
||||
cd $temp_dir
|
||||
|
||||
# Clone the repository
|
||||
git clone $clone_url .
|
||||
if $env.LAST_EXIT_CODE != 0 {
|
||||
error make {msg: "Failed to clone repository"}
|
||||
}
|
||||
|
||||
# Checkout the PR branch
|
||||
git checkout $branch_name
|
||||
if $env.LAST_EXIT_CODE != 0 {
|
||||
error make {msg: "Failed to checkout branch"}
|
||||
}
|
||||
|
||||
# Force push to the branch
|
||||
git commit --amend --no-edit
|
||||
git push -f origin $branch_name
|
||||
if $env.LAST_EXIT_CODE != 0 {
|
||||
error make {msg: "Failed to force push"}
|
||||
}
|
||||
|
||||
print $"Successfully force pushed to ($branch_name)"
|
||||
|
||||
# Clean up
|
||||
cd ..
|
||||
rm -rf $temp_dir
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue