File tree Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Expand file tree Collapse file tree 4 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ services:
117117 GIT_AUTHOR_EMAIL: [email protected] 118118 GIT_SSH_PUBLIC_KEY: "ssh-ed25519 BBBBC3NzaC1lZDI1NTE5BBBBIDR9Ibi0mATjCyx1EYg594oFkY0rghtgo+pnFHOvAcym [email protected] " 119119 GIT_SSH_PRIVATE_KEY: "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLQpiM0JsYm5OemFDMXJaWGt0ZGpFQUFBQUFCRzV2Ym1VQUFBQUVibTl1WlFBQUFBQUFBQUFCQUFBQU13QUFBQXR6YzJndFpXClF5TlRVeE9RQUFBQ0EwZlNHNHRKZ0U0d3NzZFJHSU9mZUtCWkdOSzRJYllLUHFaeFJ6cndITXBnQUFBS2k1WkJhRnVXUVcKaFFBQUFBdHpjMmd0WldReU5UVXhPUUFBQUNBMGZTRzR0SmdFNHdzc2RSR0lPZmVLQlpTks0SWJZS1BxWnhSenJ3SE1wZwowQkFnTT0KLS0tLS1FTkQgT1BFTlNTSCBQUklWQVRFIEtFWS0tLS0tCg=="
120+ SSH_ID_ALGORITHM: id_ed25519
120121 GITHUB_USERNAME: bot-mintsys
121122 GITHUB_PAT: *****
122123 GITLAB_URL: https://gitlab.com
@@ -367,6 +368,7 @@ The image can clone git repositories.
367368- `GIT_AUTHOR_EMAIL : Set user email global git config.
368369- `GIT_SSH_PUBLIC_KEY` : Public key for SSH connection.
369370- `GIT_SSH_PRIVATE_KEY` : Base64 encoded private key for SSH connection: `cat ~/.ssh/id_ed2551 | base64 -w0`
371+ - `SSH_ID_ALGORITHM` : Filename and algorithm of the SSH key file. Default is `id_ed25519`
370372- ` GITHUB_USERNAME` GitHub username for https git clone and archive download.
371373- `GITHUB_PAT` : GitHub access token for https git clone and archive download.
372374- `GITLAB_URL` : Url of GitLab instance. Default is `https://gitlab.com`.
Original file line number Diff line number Diff line change 22set -e
33
44if [[ -n " $GIT_SSH_PRIVATE_KEY " ]]; then
5- mkdir -p ~ /.ssh
6- chmod 700 ~ /.ssh
5+ key_filename=" ${SSH_ID_ALGORITHM:= id_ed25519} "
6+ mkdir -p " $HOME /.ssh"
7+ chmod 700 " $HOME /.ssh"
78 log-entrypoint ' Add SSH key from env var.'
89 decoded_git_ssh_private_key=$( echo -e " $GIT_SSH_PRIVATE_KEY " | base64 -d)
9- echo " $decoded_git_ssh_private_key " > ~ /.ssh/id_ed25519
10- chmod 600 ~ /.ssh/id_ed25519
10+ echo " $decoded_git_ssh_private_key " > " $HOME /.ssh/$key_filename "
11+ chmod 600 " $HOME /.ssh/$key_filename "
1112 eval " $( ssh-agent -s) "
12- ssh-add ~ /.ssh/id_ed25519 || (echo ' Dumping ~ /.ssh/id_ed25519 content:' && cat ~ /.ssh/id_ed25519 )
13+ ssh-add " $HOME /.ssh/$key_filename " || (echo " Dumping $HOME /.ssh/$key_filename content:" && cat " $HOME /.ssh/$key_filename " )
1314fi
Original file line number Diff line number Diff line change @@ -9,8 +9,11 @@ if [[ -n "$ADDONS_GIT_REPOS" ]]; then
99 git_clone_depth=" ${GIT_CLONE_DEPTH:= " 999" } "
1010
1111 # Setup git SSH key
12+ mkdir -p " $HOME /.ssh"
13+ chmod 700 " $HOME /.ssh"
1214 add-ssh-key
1315
16+
1417 # Make every git directory a safe directory
1518 git config --global --add safe.directory ' *'
1619
@@ -32,7 +35,7 @@ if [[ -n "$ADDONS_GIT_REPOS" ]]; then
3235 git_path=$( parse-url " $git_url " path | sed ' s/.git//g' )
3336 git_local_path=" $local_path /${git_hostname} /$git_path "
3437
35- ssh-keyscan -t rsa,dsa " $git_hostname " > ~ /.ssh/known_hosts 2> /dev/null
38+ ssh-keyscan -t rsa,dsa " $git_hostname " > " $HOME /.ssh/known_hosts" 2> /dev/null
3639
3740 if [[ ! -d " $git_local_path /.git" ]]; then
3841
Original file line number Diff line number Diff line change 22set -e
33
44if [[ -n " $GIT_SSH_PRIVATE_KEY " ]]; then
5+ key_filename=" ${SSH_ID_ALGORITHM:= id_ed25519} "
6+
57 log-entrypoint ' Remove SSH key from env var.'
68 if grep -u " $( id -u) " ssh-agent > /dev/null; then
7- if [[ -f ~ /.ssh/id_ed25519 ]]; then
8- ssh-add -d ~ /.ssh/id_ed25519 2> /dev/null || true
9+ if [[ -f " $HOME /.ssh/$key_filename " ]]; then
10+ ssh-add -d " $HOME /.ssh/$key_filename " 2> /dev/null || true
911 fi
1012 fi
11- rm -f ~ /.ssh/id_ed25519
13+ rm -f " $HOME /.ssh/$key_filename "
1214fi
You can’t perform that action at this time.
0 commit comments