diff --git a/tasks/git/task.yaml b/tasks/git/task.yaml index 009ce00..9650d59 100644 --- a/tasks/git/task.yaml +++ b/tasks/git/task.yaml @@ -54,8 +54,7 @@ spec: description: | The base image for the task. type: string - # TODO: Deprecate use of root image. - default: cgr.dev/chainguard/git:root-2.39@sha256:7759f87050dd8bacabe61354d75ccd7f864d6b6f8ec42697db7159eccd491139 + default: alpine/git:2.47.2 - name: GIT_USER_NAME type: string @@ -102,14 +101,6 @@ spec: value: $(params.VERBOSE) - name: PARAM_USER_HOME value: $(params.USER_HOME) - - name: WORKSPACE_SSH_DIRECTORY_BOUND - value: $(workspaces.ssh-directory.bound) - - name: WORKSPACE_SSH_DIRECTORY_PATH - value: $(workspaces.ssh-directory.path) - - name: WORKSPACE_BASIC_AUTH_DIRECTORY_BOUND - value: $(workspaces.basic-auth.bound) - - name: WORKSPACE_BASIC_AUTH_DIRECTORY_PATH - value: $(workspaces.basic-auth.path) script: | #!/usr/bin/env sh set -eu @@ -118,22 +109,25 @@ spec: set -x fi - if [ "${WORKSPACE_BASIC_AUTH_DIRECTORY_BOUND}" = "true" ] ; then - cp "${WORKSPACE_BASIC_AUTH_DIRECTORY_PATH}/.git-credentials" "${PARAM_USER_HOME}/.git-credentials" - cp "${WORKSPACE_BASIC_AUTH_DIRECTORY_PATH}/.gitconfig" "${PARAM_USER_HOME}/.gitconfig" + if [ -f "$(workspaces.basic-auth.path)/.git-credentials" ]; then + cp "$(workspaces.basic-auth.path)/.git-credentials" "${PARAM_USER_HOME}/.git-credentials" + cp "$(workspaces.basic-auth.path)/.gitconfig" "${PARAM_USER_HOME}/.gitconfig" chmod 400 "${PARAM_USER_HOME}/.git-credentials" chmod 400 "${PARAM_USER_HOME}/.gitconfig" fi - if [ "${WORKSPACE_SSH_DIRECTORY_BOUND}" = "true" ] ; then - cp -R "${WORKSPACE_SSH_DIRECTORY_PATH}" "${PARAM_USER_HOME}"/.ssh - chmod 700 "${PARAM_USER_HOME}"/.ssh - chmod -R 400 "${PARAM_USER_HOME}"/.ssh/* + if [ -f "$(workspaces.ssh-directory.path)" ]; then + cp -R "$(workspaces.ssh-directory.path)" "${PARAM_USER_HOME}/.ssh" + chmod 700 "${PARAM_USER_HOME}/.ssh" + chmod -R 400 "${PARAM_USER_HOME}/.ssh/*" fi - # Setting up the config for the git. - git config --global user.email "$(params.GIT_USER_EMAIL)" - git config --global user.name "$(params.GIT_USER_NAME)" + if [ -f "$(params.GIT_USER_EMAIL)" ]; then + git config --global user.email "$(params.GIT_USER_EMAIL)" + fi + if [ -f "$(params.GIT_USER_NAME)" ]; then + git config --global user.name "$(params.GIT_USER_NAME)" + fi eval '$(params.GIT_SCRIPT)'