Skip to content

Commit 13ebb64

Browse files
committed
fix: Fix SSH_AUTH_SOCK changes in github actions (upgrade makefile)
1 parent 9d4ae51 commit 13ebb64

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Makefile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ BUILD_TOOLS_VERSION ?= v0.11.0
55
BUILD_TOOLS_DOCKER_REPO ?= mineiros/build-tools
66
BUILD_TOOLS_DOCKER_IMAGE ?= ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}
77

8-
# If running in CI (e.g. GitHub Actions)
9-
# https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
108
#
11-
# To disable TF_IN_AUTOMATION in CI set it to empty
9+
# Some CI providers such as GitHub Actions, CircleCI, and TravisCI are setting
10+
# the CI environment variable to a non-empty value by default to indicate that
11+
# the current workflow is running in a Continuous Integration environment.
12+
#
13+
# If TF_IN_AUTOMATION is set to any non-empty value, Terraform adjusts its
14+
# output to avoid suggesting specific commands to run next.
1215
# https://www.terraform.io/docs/commands/environment-variables.html#tf_in_automation
1316
#
1417
# We are using GNU style quiet commands to disable set V to non-empty e.g. V=1
@@ -28,18 +31,16 @@ ifndef NOCOLOR
2831
RESET := $(shell tput -Txterm sgr0)
2932
endif
3033

31-
# We are creating docker volumes for /go and /terraform that are unique per
32-
# repository to reuse dependencies between different docker run commands.
33-
VOLUME_PREFIX ?= mineiros_build_tools
34-
VOLUME_SUFFIX ?= $(notdir $(shell git rev-parse --show-toplevel || "build"))
35-
DOCKER_RUN_FLAGS += -v ${VOLUME_PREFIX}-terraform-${VOLUME_SUFFIX}:/terraform
36-
DOCKER_RUN_FLAGS += -v ${VOLUME_PREFIX}-go-${VOLUME_SUFFIX}:/go
37-
DOCKER_RUN_FLAGS += -v ${PWD}:/build
34+
GIT_TOPLEVEl = $(shell git rev-parse --show-toplevel)
35+
36+
DOCKER_RUN_FLAGS += -v ${GIT_TOPLEVEl}:/build
3837
DOCKER_RUN_FLAGS += --rm
3938
DOCKER_RUN_FLAGS += -e TF_IN_AUTOMATION
4039

41-
DOCKER_SSH_FLAGS += -e SSH_AUTH_SOCK=/ssh-agent
42-
DOCKER_SSH_FLAGS += -v ${SSH_AUTH_SOCK}:/ssh-agent
40+
ifdef SSH_AUTH_SOCK
41+
DOCKER_SSH_FLAGS += -e SSH_AUTH_SOCK=/ssh-agent
42+
DOCKER_SSH_FLAGS += -v ${SSH_AUTH_SOCK}:/ssh-agent
43+
endif
4344

4445
DOCKER_AWS_FLAGS += -e AWS_ACCESS_KEY_ID
4546
DOCKER_AWS_FLAGS += -e AWS_SECRET_ACCESS_KEY
@@ -76,9 +77,11 @@ test/unit-tests:
7677
.PHONY: clean
7778
clean:
7879
$(call rm-command,.terraform)
80+
$(call rm-command,.terraform.lock.hcl)
7981
$(call rm-command,*.tfplan)
8082
$(call rm-command,*/*/.terraform)
8183
$(call rm-command,*/*/*.tfplan)
84+
$(call rm-command,*/*/.terraform.lock.hcl)
8285

8386
## Display help for all targets
8487
.PHONY: help

0 commit comments

Comments
 (0)