Skip to content

Commit

Permalink
(actions) sync ssh commands
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh committed Apr 3, 2024
1 parent d139a1e commit 522a665
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ jobs:
SSH_ARG=()
if [[ -n "${SSH_KEY}" ]]
then
SSH_KEY_PATH="${HOME}/.ssh/ci_ssh_key"
SSH_KEY_PATH="${HOME}"/.ssh/ci_ssh_key
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh\e[0m"
mkdir -p "${HOME}"/.ssh
echo "${SSH_KEY}" > "${SSH_KEY_PATH}"
chmod 600 "${SSH_KEY_PATH}"
Expand Down
1 change: 1 addition & 0 deletions ci/azure-pipelines.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ steps:
targetType: inline
script: |
# START SSH ONLY
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh\e[0m"
mkdir -p "${HOME}"/.ssh
cp $(deployKey.secureFilePath) "${HOME}"/.ssh/ci_ssh_key
if [[ -n "${SSH_KNOWN_HOSTS}" ]]
Expand Down
1 change: 1 addition & 0 deletions ci/azure-pipelines.multiple_pkgs.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ stages:
targetType: inline
script: |
# START SSH ONLY
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh\e[0m"
mkdir -p "${HOME}"/.ssh
cp $(deployKey.secureFilePath) "${HOME}"/.ssh/ci_ssh_key
if [[ -n "${SSH_KNOWN_HOSTS}" ]]
Expand Down
17 changes: 9 additions & 8 deletions ci/main/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,22 @@ runs:
PULLREQUEST=${PULLREQUEST:-false}
SSH_KEY="${{ inputs.ssh-key }}"
SSH_KNOWN_HOSTS="${{ inputs.ssh-known-hosts }}"
SSH_ARG=()
if [[ -n "${SSH_KEY}" ]]
then
SSH_ARG="--ssh"
SSH_KEY_PATH="${HOME}"/.ssh/ci_ssh_key
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh\e[0m"
mkdir -p "${HOME}"/.ssh
echo "${SSH_KEY}" > "${HOME}"/.ssh/ci_ssh_key
SSH_KEY_ARG="--ssh-key=${HOME}/.ssh/ci_ssh_key"
echo "${SSH_KEY}" > "${SSH_KEY_PATH}"
SSH_ARG+=("--ssh" "--ssh-key=${SSH_KEY_PATH}")
fi
if [[ -n "${SSH_KNOWN_HOSTS}" ]]
then
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh \e[0m"
mkdir -p ${HOME}/.ssh
echo -e "\e[35;1mmkdir -p ${HOME}/.ssh\e[0m"
mkdir -p "${HOME}"/.ssh
for host in ${SSH_KNOWN_HOSTS}
do
echo -e "\e[35;1mssh-keyscan -t rsa -H \"${host}\" 2>&1 | tee -a ${HOME}/.ssh/known_hosts \e[0m"
echo -e "\e[35;1mssh-keyscan -t rsa -H \"${host}\" 2>&1 | tee -a ${HOME}/.ssh/known_hosts\e[0m"
ssh-keyscan -t rsa -H "${host}" 2>&1 | tee -a "${HOME}"/.ssh/known_hosts
done
fi
Expand All @@ -82,8 +84,7 @@ runs:
--branch="${BRANCH}" \
--commit="${GITHUB_SHA}" \
--pullrequest="${PULLREQUEST}" \
"${SSH_ARG}" \
"${SSH_KEY_ARG}"
"${SSH_ARG[@]}"
echo "::endgroup::"
shell: bash

Expand Down

0 comments on commit 522a665

Please sign in to comment.