Skip to content

Commit fb9d854

Browse files
committed
refactor(ci): combined image scan logic in build stage
1 parent d2f9ace commit fb9d854

3 files changed

Lines changed: 8 additions & 19 deletions

File tree

ci/container-scan.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,10 @@
33
image:
44
name: aquasec/trivy:${TRIVY_VERSION}
55
entrypoint: [""]
6-
before_script:
7-
- export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}
8-
- apk add --no-cache aws-cli
9-
- export AWS_DEFAULT_REGION="${AWS_DEFAULT_REGION:-ap-south-1}"
10-
- STS_OUTPUT=$(aws sts assume-role-with-web-identity --region "$AWS_DEFAULT_REGION" --role-arn "${AWS_ROLE_ARN}" --role-session-name gitlab-ci-${CI_JOB_ID} --web-identity-token "${GITLAB_OIDC_TOKEN}" --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" --output text)
11-
- export AWS_ACCESS_KEY_ID=$(echo $STS_OUTPUT | awk '{print $1}')
12-
- export AWS_SECRET_ACCESS_KEY=$(echo $STS_OUTPUT | awk '{print $2}')
13-
- export AWS_SESSION_TOKEN=$(echo $STS_OUTPUT | awk '{print $3}')
14-
- unset STS_OUTPUT
15-
- aws ecr get-login-password --region "$AWS_DEFAULT_REGION" |
16-
trivy registry login
17-
--username AWS
18-
--password-stdin
19-
${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
206
script:
21-
- trivy image --exit-code 0 --no-progress --format json -o ${REPORT_FILE} ${IMAGE}
22-
- trivy image --exit-code 1 --severity CRITICAL --no-progress ${IMAGE}
7+
- trivy fs .
8+
# - trivy image --exit-code 0 --no-progress --format json -o ${REPORT_FILE} ${IMAGE}
9+
# - trivy image --exit-code 1 --severity CRITICAL --no-progress ${IMAGE}
2310
artifacts:
2411
reports:
2512
container_scanning: ${REPORT_FILE}

ci/templates.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@
3838
.gitops_setup:
3939
image: alpine:latest
4040
before_script:
41-
- apk add --no-cache git yq
41+
- apk add --no-cache git curl
42+
- curl -fsSL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq
43+
- chmod +x /usr/local/bin/yq
4244
- git config --global user.email "${GITLAB_USER_EMAIL}"
4345
- git config --global user.name "${GITLAB_USER_NAME}"
44-
- git config --global url."https://oauth2:${GITOPS_ACCESS_TOKEN}@gitlab.com/".insteadOf "https://gitlab.com/"
4546

4647
# ---- Shared rule sets ----
4748

ci/update-manifests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- container_scanning:transcoder
66
script:
77
- |
8+
GITOPS_REPO="https://oauth2:${GITOPS_ACCESS_TOKEN}@gitlab.com/subrotokumar/playstack-ops.git"
89
git clone ${GITOPS_REPO} gitops
910
cd gitops
1011
git checkout ${GITOPS_BRANCH}
@@ -30,7 +31,7 @@ update:manifests:dev:
3031
stage: update-manifests-dev
3132
variables:
3233
ENVIRONMENT: dev
33-
VALUES_FILE: helm/values.dev.yaml
34+
VALUES_FILE: helm/values.yaml
3435
rules:
3536
- if: '$CI_COMMIT_BRANCH == "dev"'
3637

0 commit comments

Comments
 (0)