From 70a1337d0012521e0a8da0076a1215f68cb81f74 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 5 Mar 2024 12:25:19 +0100 Subject: [PATCH] Final touches for action v1 Signed-off-by: Carlos Eduardo Arango Gutierrez --- Makefile | 2 +- cmd/action/ci/ci.go | 3 ++- cmd/action/ci/cleanup.go | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c5977ab4..70f4d65d 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) build-action: @rm -rf bin - GOOS=linux $(GO_CMD) build -v -ldflags "-s -w -extldflags '-static'" -o /go/bin/$(BINARY_NAME) cmd/action/main.go + GOOS=linux $(GO_CMD) build -o /go/bin/$(BINARY_NAME) cmd/action/main.go build-cli: @rm -rf bin diff --git a/cmd/action/ci/ci.go b/cmd/action/ci/ci.go index ec2ba76c..525375fa 100644 --- a/cmd/action/ci/ci.go +++ b/cmd/action/ci/ci.go @@ -56,9 +56,10 @@ func Run(log *logger.FunLogger) error { func setCfgName(cfg *v1alpha1.Environment) { sha := os.Getenv("GITHUB_SHA") + attempt := os.Getenv("GITHUB_RUN_ATTEMPT") // short sha if len(sha) > 8 { sha = sha[:8] } - cfg.Name = fmt.Sprintf("ci-%s", sha) + cfg.Name = fmt.Sprintf("ci%s-%s", attempt, sha) } diff --git a/cmd/action/ci/cleanup.go b/cmd/action/ci/cleanup.go index a920835b..ff403d39 100644 --- a/cmd/action/ci/cleanup.go +++ b/cmd/action/ci/cleanup.go @@ -29,6 +29,23 @@ import ( func cleanup(log *logger.FunLogger) error { log.Info("Running Cleanup function") + // Map INPUT_AWS_ACCESS_KEY_ID and INPUT_AWS_SECRET_ACCESS_KEY + // to AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY + accessKeyID := os.Getenv("INPUT_AWS_ACCESS_KEY_ID") + if accessKeyID == "" { + log.Error(fmt.Errorf("aws access key id not provided")) + os.Exit(1) + } + + secretAccessKey := os.Getenv("INPUT_AWS_SECRET_ACCESS_KEY") + if secretAccessKey == "" { + log.Error(fmt.Errorf("aws secret access key not provided")) + os.Exit(1) + } + + os.Setenv("AWS_ACCESS_KEY_ID", accessKeyID) + os.Setenv("AWS_SECRET_ACCESS_KEY", secretAccessKey) + configFile := os.Getenv("INPUT_HOLODECK_CONFIG") if configFile == "" { log.Error(fmt.Errorf("config file not provided"))