Skip to content

Commit ddb5236

Browse files
committed
fixup! Add Buildkite pipeline for updating hackage.nix and stackage.nix
Use github tokens for authentication to push to github.
1 parent 58e156b commit ddb5236

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

scripts/update-external.nix

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,36 @@
44

55
with stdenv.lib;
66

7-
writeScript "update-${name}-nix.sh" ''
8-
#!${stdenv.shell}
7+
let
8+
repo = "github.com/input-output-hk/${name}.nix.git";
9+
tokenFile = "/run/keys/buildkite-nix-tools-token";
10+
githubUser = "iohk-devops";
11+
in
12+
writeScript "update-${name}-nix.sh" ''
13+
#!${stdenv.shell}
914
10-
set -euo pipefail
15+
set -euo pipefail
1116
12-
export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
17+
export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
1318
14-
${script}
19+
${script}
1520
16-
git add .
17-
git commit --allow-empty -m "Automatic update for $(date)"
21+
git add .
22+
git commit --allow-empty -m "Automatic update for $(date)"
1823
19-
rev=$(git rev-parse HEAD)
24+
rev=$(git rev-parse HEAD)
2025
21-
git push
26+
if [ -f ${tokenFile} ];
27+
echo "Authenticating as ${githubUser}"
28+
auth="${githubUser}:$(head -n1 ${tokenFile})@"
29+
else
30+
echo "There is no GitHub token in ${tokenFile}"
31+
auth=""
32+
fi
2233
23-
cd ..
34+
git push "https://''${auth}${repo}"
2435
25-
nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
26-
''
36+
cd ..
37+
38+
nix-prefetch-git https://${repo} --rev "$rev" | tee ${name}-src.json
39+
''

0 commit comments

Comments
 (0)