|
1 | | -{ stdenv, writeScript, glibc, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }: |
| 1 | +{ stdenv, writeScript, glibc, coreutils, git, openssh |
| 2 | +, nix-tools, cabal-install, nix-prefetch-git }: |
2 | 3 |
|
3 | 4 | { name, script }: |
4 | 5 |
|
5 | 6 | with stdenv.lib; |
6 | 7 |
|
7 | | -writeScript "update-${name}-nix.sh" '' |
8 | | - #!${stdenv.shell} |
| 8 | +let |
| 9 | + repoHTTPS = "https://github.com/input-output-hk/${name}.nix.git"; |
| 10 | + repoSSH = "git@github.com:input-output-hk/${name}.nix.git"; |
| 11 | + sshKey = "/run/keys/buildkite-${name}-ssh-private"; |
| 12 | +in |
| 13 | + writeScript "update-${name}-nix.sh" '' |
| 14 | + #!${stdenv.shell} |
9 | 15 |
|
10 | | - set -euo pipefail |
| 16 | + set -euo pipefail |
11 | 17 |
|
12 | | - export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}" |
| 18 | + export PATH="${makeBinPath [ coreutils glibc git openssh nix-tools cabal-install nix-prefetch-git ]}" |
13 | 19 |
|
14 | | - ${script} |
| 20 | + ${script} |
15 | 21 |
|
16 | | - git add . |
17 | | - git commit --allow-empty -m "Automatic update for $(date)" |
| 22 | + echo "Committing changes..." |
| 23 | + export GIT_COMMITTER_NAME="IOHK" |
| 24 | + export GIT_COMMITTER_EMAIL="devops+nix-tools@iohk.io" |
| 25 | + export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME" |
| 26 | + export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL" |
| 27 | + git add . |
| 28 | + git commit --allow-empty --message "Automatic update for $(date)" |
18 | 29 |
|
19 | | - rev=$(git rev-parse HEAD) |
| 30 | + rev=$(git rev-parse HEAD) |
20 | 31 |
|
21 | | - git push |
| 32 | + if [ -e ${sshKey} ] |
| 33 | + then |
| 34 | + echo "Authenticating using SSH with ${sshKey}" |
| 35 | + export GIT_SSH_COMMAND="ssh -i ${sshKey} -F /dev/null" |
| 36 | + else |
| 37 | + echo "There is no SSH key at ${sshKey}" |
| 38 | + echo "Git push may not work." |
| 39 | + fi |
22 | 40 |
|
23 | | - cd .. |
| 41 | + git push ${repoSSH} |
24 | 42 |
|
25 | | - nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json |
26 | | -'' |
| 43 | + cd .. |
| 44 | +
|
| 45 | + nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json |
| 46 | + '' |
0 commit comments