From c084eaf02ce64c5e4c822724fd757d259224cd7a Mon Sep 17 00:00:00 2001 From: khalifapro <81648906+khalifapro@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:41:38 +0200 Subject: [PATCH] Fix cicd prod (#13) * fix cicd prod Signed-off-by: Ayman * clean up Signed-off-by: Ayman Signed-off-by: Ayman Co-authored-by: Ayman --- .circleci/config.yml | 45 +++++++++++--------------------------------- Makefile | 6 +++++- cmd/jira/jira.go | 5 +++-- 3 files changed, 19 insertions(+), 37 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 70acb42..cdbc87f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: command: git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/LF-Engineering".insteadOf "https://github.com/LF-Engineering" - run: name: Build Executable - command: make jira + command: make - setup_remote_docker - persist_to_workspace: root: ./ @@ -34,16 +34,15 @@ jobs: command: | eval "echo 'export AWS_ACCESS_KEY_ID=\$$AWS_ACCESS_KEY_ID_ENV_VAR'" >> $BASH_ENV eval "echo 'export AWS_SECRET_ACCESS_KEY=\$$AWS_SECRET_ACCESS_KEY_ENV_VAR'" >> $BASH_ENV - eval "echo 'export AWS_ACCOUNT_ID=\$$AWS_ACCOUNT_ID_ENV_VAR'" >> $BASH_ENV eval "echo 'export AWS_DEFAULT_REGION=\$$AWS_REGION_ENV_VAR'" >> $BASH_ENV - run: name: Setup common environment variables command: | - echo 'export FULL_IMAGE_NAME="${AWS_ACCOUNT_ID_ENV_VAR}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/insights-connector-jira:${TAG}"' >> $BASH_ENV + echo 'export FULL_IMAGE_NAME="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/insights-connector-jira:${TAG}"' >> $BASH_ENV - run: name: Authenticate ECR command: | - aws ecr get-login-password | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID_ENV_VAR}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com + aws ecr get-login-password | docker login --username AWS --password-stdin ${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com - run: name: setup the docker repository to be able to push image in aws (should succeed on first time & allowed to fail later) command: | @@ -62,26 +61,14 @@ jobs: AWS_REGION_ENV_VAR: AWS_REGION_DEV AWS_ACCESS_KEY_ID_ENV_VAR: AWS_ACCESS_KEY_ID_DEV AWS_SECRET_ACCESS_KEY_ENV_VAR: AWS_SECRET_ACCESS_KEY_DEV - AWS_ACCOUNT_ID_ENV_VAR: "395594542180" STAGE: dev TAG: latest - deploy_test: - <<: *deploy - environment: - AWS_ACCESS_KEY_ID_ENV_VAR: AWS_ACCESS_KEY_ID_TEST - AWS_SECRET_ACCESS_KEY_ENV_VAR: AWS_SECRET_ACCESS_KEY_TEST - AWS_ACCOUNT_ID_ENV_VAR: AWS_ACCOUNT_ID_TEST - AWS_REGION_ENV_VAR: AWS_REGION_TEST - STAGE: test - TAG: test - deploy_prod: <<: *deploy environment: AWS_ACCESS_KEY_ID_ENV_VAR: AWS_ACCESS_KEY_ID_PROD AWS_SECRET_ACCESS_KEY_ENV_VAR: AWS_SECRET_ACCESS_KEY_PROD - AWS_ACCOUNT_ID_ENV_VAR: AWS_ACCOUNT_ID_PROD AWS_REGION_ENV_VAR: AWS_REGION_PROD STAGE: prod TAG: stable @@ -89,32 +76,20 @@ jobs: workflows: build-connector: jobs: - - build - - deploy_dev: - requires: - - build + - build: filters: - branches: - only: main tags: - ignore: /.*/ - - approve_test: - type: approval + only: /.*/ + - deploy_dev: + context: + - development requires: - build filters: branches: - ignore: /.*/ + only: main tags: - only: /^v\d+(\.\d+)?(\.\d+)?$/ - - deploy_test: - requires: - - approve_test - filters: - branches: ignore: /.*/ - tags: - only: /^v\d+(\.\d+)?(\.\d+)?$/ - approve_prod: type: approval requires: @@ -125,6 +100,8 @@ workflows: tags: only: /^v\d+(\.\d+)?(\.\d+)?$/ - deploy_prod: + context: + - production requires: - approve_prod filters: diff --git a/Makefile b/Makefile index 625fb2f..fe502c0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -GO_BIN_FILES=cmd/jira/jira.go +GO_BIN_FILES=cmd/jira/jira.go #for race CGO_ENABLED=1 GO_ENV=GOOS=linux CGO_ENABLED=0 @@ -20,12 +20,16 @@ jira: ${GO_BIN_FILES} fmt: ${GO_BIN_FILES} ${GO_FMT} ${GO_BIN_FILES} lint: ${GO_BIN_FILES} + go get -u golang.org/x/lint/golint ${GO_LINT} ${GO_BIN_FILES} vet: ${GO_BIN_FILES} + go mod vendor ${GO_VET} ${GO_BIN_FILES} imports: ${GO_BIN_FILES} + go install golang.org/x/tools/cmd/goimports@latest ${GO_IMPORTS} ${GO_BIN_FILES} errcheck: ${GO_BIN_FILES} + go install github.com/kisielk/errcheck@latest ${GO_ERRCHECK} ${GO_BIN_FILES} check: fmt lint imports vet errcheck clean: diff --git a/cmd/jira/jira.go b/cmd/jira/jira.go index f660913..b059cef 100644 --- a/cmd/jira/jira.go +++ b/cmd/jira/jira.go @@ -71,7 +71,8 @@ const ( // Failed status Failed = "failed" // Success status - Success = "success" + Success = "success" + // JiraIssue type JiraIssue = "issue" ) @@ -904,7 +905,7 @@ func (j *DSJira) Init(ctx *shared.Ctx) (err error) { } if ctx.Debug > 1 { - j.log.WithFields(logrus.Fields{"operation": "Init"}).Debugf("Jira: %+v\nshared context: %s\nModel: %+v", j, ctx.Info()) + j.log.WithFields(logrus.Fields{"operation": "Init"}).Debugf("Jira: %+v\nshared context: %s", j, ctx.Info()) } if ctx.Debug > 0 {