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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,5 +2,8 @@
set -eu
if [ ! -f "$HOME/.ssh/known_hosts" ]; then
touch $HOME/.ssh/known_hosts
fi
chmod 600 $HOME/.ssh/known_hosts