Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Fix cicd prod (#13)
Browse files Browse the repository at this point in the history
* fix cicd prod

Signed-off-by: Ayman <[email protected]>

* clean up

Signed-off-by: Ayman <[email protected]>

Signed-off-by: Ayman <[email protected]>
Co-authored-by: Ayman <[email protected]>
  • Loading branch information
khalifapro and enkhalifapro authored Aug 30, 2022
1 parent c5450a0 commit c084eaf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 37 deletions.
45 changes: 11 additions & 34 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
command: git config --global url."https://${GITHUB_TOKEN}:[email protected]/LF-Engineering".insteadOf "https://github.com/LF-Engineering"
- run:
name: Build Executable
command: make jira
command: make
- setup_remote_docker
- persist_to_workspace:
root: ./
Expand All @@ -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: |
Expand All @@ -62,59 +61,35 @@ 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

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:
Expand All @@ -125,6 +100,8 @@ workflows:
tags:
only: /^v\d+(\.\d+)?(\.\d+)?$/
- deploy_prod:
context:
- production
requires:
- approve_prod
filters:
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions cmd/jira/jira.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ const (
// Failed status
Failed = "failed"
// Success status
Success = "success"
Success = "success"
// JiraIssue type
JiraIssue = "issue"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c084eaf

Please sign in to comment.