diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4237e59e4..22ea2a8f7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -118,15 +118,16 @@ jobs: # shellcheck disable=SC2296 TARGET_IMAGE="${{ env.REGISTRY }}/tue-robotics/tue-env-ros-${{ matrix.ros-distro }}${IMAGE_FLAVOR}:${IMAGE_TAG}-${{ matrix.platform }}" SSH_KNOWN_HOSTS="github.com" - SSH_ARG=() + SSH_ARGS=() 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}" eval "$(ssh-agent -s)" - SSH_ARG+=("--ssh" "--ssh-key=${SSH_KEY_PATH}") + SSH_ARGS+=("--ssh" "--ssh-key=${SSH_KEY_PATH}") fi if [[ -n "${SSH_KNOWN_HOSTS}" ]] then @@ -168,7 +169,7 @@ jobs: --virtualenv-include-system-site-packages="${VENV_INCLUDE_SYSTEM_SITE}" \ --docker_user="${DOCKER_USER}" \ --docker_user_id="${DOCKER_USER_ID}" \ - "${SSH_ARG[@]}" + "${SSH_ARGS[@]}" echo -e "\e[35;1mimage=${TARGET_IMAGE} >> \${GITHUB_OUTPUT}\e[0m" echo "image=${TARGET_IMAGE}" >> "${GITHUB_OUTPUT}" echo -e "\e[35;1mtag=${IMAGE_TAG} >> \${GITHUB_OUTPUT}\e[0m" diff --git a/ci/azure-pipelines.example.yml b/ci/azure-pipelines.example.yml index ad648d922..9d806d510 100644 --- a/ci/azure-pipelines.example.yml +++ b/ci/azure-pipelines.example.yml @@ -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}" ]] diff --git a/ci/azure-pipelines.multiple_pkgs.example.yml b/ci/azure-pipelines.multiple_pkgs.example.yml index a79395b45..c9cbaff70 100644 --- a/ci/azure-pipelines.multiple_pkgs.example.yml +++ b/ci/azure-pipelines.multiple_pkgs.example.yml @@ -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}" ]] diff --git a/ci/main/action.yml b/ci/main/action.yml index dc6ac6204..bc00cea64 100644 --- a/ci/main/action.yml +++ b/ci/main/action.yml @@ -59,20 +59,22 @@ runs: PULLREQUEST=${PULLREQUEST:-false} SSH_KEY="${{ inputs.ssh-key }}" SSH_KNOWN_HOSTS="${{ inputs.ssh-known-hosts }}" + SSH_ARGS=() 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_ARGS+=("--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 @@ -82,8 +84,7 @@ runs: --branch="${BRANCH}" \ --commit="${GITHUB_SHA}" \ --pullrequest="${PULLREQUEST}" \ - "${SSH_ARG}" \ - "${SSH_KEY_ARG}" + "${SSH_ARGS[@]}" echo "::endgroup::" shell: bash