fix: only attempt to create file if it doesn't exist yet

On self-hosted runners it can happen that an action (docker container) is cached, resulting in aborting this script because the know_hosts file already exists. 
This if clause fixes it.
Setting permissions is intentionally outside the if clause because in all cases we want to reset perms.
This commit is contained in:
Steven
2025-12-07 12:33:49 +01:00
committed by GitHub
parent 400135b4a7
commit 1002e5f311
+4 -1
View File
@@ -2,5 +2,8 @@
set -eu set -eu
touch $HOME/.ssh/known_hosts if [ ! -f "$HOME/.ssh/known_hosts" ]; then
touch $HOME/.ssh/known_hosts
fi
chmod 600 $HOME/.ssh/known_hosts chmod 600 $HOME/.ssh/known_hosts