diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..62c89355 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 78a0a495..84a6f68a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ -FROM alpine:3 +FROM alpine:3.19 -RUN ["/bin/sh", "-c", "apk add --update --no-cache bash ca-certificates curl git jq openssh"] +RUN ["/bin/sh", "-c", "apk add --update --no-cache bash ca-certificates curl git jq openssh aws-cli"] COPY ["src", "/src/"] + ENTRYPOINT ["/src/main.sh"] diff --git a/action.yml b/action.yml index 07724456..32debccd 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,18 @@ inputs: tf_actions_fmt_write: description: 'Write Terragrunt fmt changes to source files.' default: false + ssh_private_key: + description: 'Private Key for authentication with non-public modules' + default: "" + github_username: + description: 'Github username for cloning private repos' + default: "" + github_token: + description: 'Github token for cloning private repos' + default: "" + tags_override: + description: 'Override terraform "tags" with environment variables. Injecting TF_VAR_tags' + default: "" outputs: tf_actions_output: description: 'The Terragrunt outputs in JSON format.' @@ -44,4 +56,4 @@ outputs: description: 'Whether or not the Terragrunt formatting was written to source files.' runs: using: 'docker' - image: './Dockerfile' + image: './Dockerfile' \ No newline at end of file diff --git a/src/main.sh b/src/main.sh index ae9b3963..dc8dcb07 100755 --- a/src/main.sh +++ b/src/main.sh @@ -73,6 +73,24 @@ function parseInputs { if [ -n "${TF_WORKSPACE}" ]; then tfWorkspace="${TF_WORKSPACE}" fi + github_username="" + github_token="" + if [ "${INPUT_GITHUB_TOKEN}" != "" ]; then + git config --global url."https://${INPUT_GITHUB_USERNAME}:${INPUT_GITHUB_TOKEN}@github.com".insteadOf https://github.com + fi + if [ "${INPUT_TAGS_OVERRIDE}" != null ]; then + echo "Tags Are Overriden New Tags are as below" + echo "$INPUT_TAGS_OVERRIDE" + export TF_VAR_tags="$INPUT_TAGS_OVERRIDE" + fi + ssh_private_key="" + if [ "${INPUT_SSH_PRIVATE_KEY}" != "" ]; then + echo "SSH Key found" + mkdir -p /tmp/.ssh + echo "${INPUT_SSH_PRIVATE_KEY}" > /tmp/.ssh/id_rsa + chmod 600 /tmp/.ssh/id_rsa + export GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null -i /tmp/.ssh/id_rsa" + fi } function configureCLICredentials { @@ -164,7 +182,6 @@ function main { configureCLICredentials installTerraform cd ${GITHUB_WORKSPACE}/${tfWorkingDir} - case "${tfSubcommand}" in fmt) installTerragrunt @@ -210,3 +227,4 @@ function main { } main "${*}" +