From 782b80a1eef8589ce1c4fd1df9ba1cddc414c799 Mon Sep 17 00:00:00 2001 From: Humayun Akhtar Date: Wed, 16 Aug 2023 13:04:28 +0400 Subject: [PATCH 1/5] Add GitHub username token support (#1) --- .gitignore | 1 + Dockerfile | 1 + action.yml | 8 +++++++- src/main.sh | 7 ++++++- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 .gitignore 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..a4601fa8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,5 @@ RUN ["/bin/sh", "-c", "apk add --update --no-cache bash ca-certificates curl git COPY ["src", "/src/"] + ENTRYPOINT ["/src/main.sh"] diff --git a/action.yml b/action.yml index 07724456..f139ba27 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,12 @@ inputs: tf_actions_fmt_write: description: 'Write Terragrunt fmt changes to source files.' default: false + github_username: + description: 'Github username for cloning private repos' + default: "" + github_token: + description: 'Github token for cloning private repos' + default: "" outputs: tf_actions_output: description: 'The Terragrunt outputs in JSON format.' @@ -44,4 +50,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..abdad53c 100755 --- a/src/main.sh +++ b/src/main.sh @@ -73,6 +73,11 @@ 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 } function configureCLICredentials { @@ -164,7 +169,6 @@ function main { configureCLICredentials installTerraform cd ${GITHUB_WORKSPACE}/${tfWorkingDir} - case "${tfSubcommand}" in fmt) installTerragrunt @@ -210,3 +214,4 @@ function main { } main "${*}" + From b6275e6c8a425f0ac4d7978d24a04ea7fa4fdfee Mon Sep 17 00:00:00 2001 From: Humayun Akhtar Date: Thu, 17 Aug 2023 15:06:28 +0400 Subject: [PATCH 2/5] Feature/add terraform tags override (#2) * add tags override * add globbing * tags overrident * check on null * remove junk * update --- action.yml | 3 +++ src/main.sh | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/action.yml b/action.yml index f139ba27..c9b9e37a 100644 --- a/action.yml +++ b/action.yml @@ -39,6 +39,9 @@ inputs: 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.' diff --git a/src/main.sh b/src/main.sh index abdad53c..b3af3cf7 100755 --- a/src/main.sh +++ b/src/main.sh @@ -78,6 +78,11 @@ function parseInputs { 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 } function configureCLICredentials { From d80eaee73f9774b1e5a674242a814d567195876c Mon Sep 17 00:00:00 2001 From: Usman Shahid Date: Fri, 6 Oct 2023 15:12:30 +0500 Subject: [PATCH 3/5] Added aws-cli to the docker image (#3) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a4601fa8..ed0ba1eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM alpine:3 -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/"] From d1066e3c93fdfc2325c2a007d70737e527d0da53 Mon Sep 17 00:00:00 2001 From: Humayun Date: Tue, 12 Dec 2023 21:27:35 +0400 Subject: [PATCH 4/5] Feature/add ssh key support (#5) --- action.yml | 3 +++ src/main.sh | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/action.yml b/action.yml index c9b9e37a..32debccd 100644 --- a/action.yml +++ b/action.yml @@ -33,6 +33,9 @@ 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: "" diff --git a/src/main.sh b/src/main.sh index b3af3cf7..dc8dcb07 100755 --- a/src/main.sh +++ b/src/main.sh @@ -83,6 +83,14 @@ function parseInputs { 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 { From 70ba7be21c37af0d9364777d077d9d89a1731afe Mon Sep 17 00:00:00 2001 From: Muhammad Muneeb Date: Thu, 23 May 2024 14:51:21 +0500 Subject: [PATCH 5/5] alpine v3.19 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ed0ba1eb..84a6f68a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3 +FROM alpine:3.19 RUN ["/bin/sh", "-c", "apk add --update --no-cache bash ca-certificates curl git jq openssh aws-cli"]