Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpine image #22

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
14 changes: 13 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand All @@ -44,4 +56,4 @@ outputs:
description: 'Whether or not the Terragrunt formatting was written to source files.'
runs:
using: 'docker'
image: './Dockerfile'
image: './Dockerfile'
20 changes: 19 additions & 1 deletion src/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -164,7 +182,6 @@ function main {
configureCLICredentials
installTerraform
cd ${GITHUB_WORKSPACE}/${tfWorkingDir}

case "${tfSubcommand}" in
fmt)
installTerragrunt
Expand Down Expand Up @@ -210,3 +227,4 @@ function main {
}

main "${*}"