Skip to content

Commit f766e7b

Browse files
committed
fixup - Use ssh auth instead of OAuth
Oauth tokens have access to all repos, whereas ssh keys have access per-repo.
1 parent ddb5236 commit f766e7b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

scripts/update-external.nix

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
with stdenv.lib;
66

77
let
8-
repo = "github.com/input-output-hk/${name}.nix.git";
9-
tokenFile = "/run/keys/buildkite-nix-tools-token";
10-
githubUser = "iohk-devops";
8+
repoHTTPS = "https://github.com/input-output-hk/${name}.nix.git";
9+
repoSSH = "[email protected]:input-output-hk/${name}.nix.git";
10+
sshKey = "/run/keys/buildkite-${name}-ssh-private";
1111
in
1212
writeScript "update-${name}-nix.sh" ''
1313
#!${stdenv.shell}
@@ -23,17 +23,17 @@ in
2323
2424
rev=$(git rev-parse HEAD)
2525
26-
if [ -f ${tokenFile} ];
27-
echo "Authenticating as ${githubUser}"
28-
auth="${githubUser}:$(head -n1 ${tokenFile})@"
26+
if [ -e ${sshKey} ];
27+
echo "Authenticating using SSH with ${sshKey}"
28+
export GIT_SSH_COMMAND="ssh -i ${sshKey} -F /dev/null"
2929
else
30-
echo "There is no GitHub token in ${tokenFile}"
31-
auth=""
30+
echo "There is no SSH key at ${sshKey}"
31+
echo "Git push may not work."
3232
fi
3333
34-
git push "https://''${auth}${repo}"
34+
git push ${repoSSH}
3535
3636
cd ..
3737
38-
nix-prefetch-git https://${repo} --rev "$rev" | tee ${name}-src.json
38+
nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
3939
''

0 commit comments

Comments
 (0)