Skip to content

Commit f6c9fc6

Browse files
authored
Add docker login for daily scan workflow image scanning (#237)
1 parent 7d70e9d commit f6c9fc6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.github/actions/image_scan/action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ inputs:
1111
severity:
1212
required: true
1313
description: "List of severities that will cause a failure"
14+
logout:
15+
required: true
16+
description: |
17+
Whether to logout of public AWS ECR. Set to 'true' for PR workflows to avoid potential call failures,
18+
'false' for daily scans which has a higher bar for passing regularly and specifically wants to sign in.
1419
1520
runs:
1621
using: "composite"
@@ -22,6 +27,7 @@ runs:
2227
# ensure we can make unauthenticated call. This is important for making the pr_build workflow run on
2328
# PRs created from forked repos.
2429
- name: Logout of public AWS ECR
30+
if: inputs.logout == 'true'
2531
shell: bash
2632
run: docker logout public.ecr.aws
2733

@@ -30,4 +36,4 @@ runs:
3036
with:
3137
image-ref: ${{ inputs.image-ref }}
3238
severity: ${{ inputs.severity }}
33-
exit-code: '1'
39+
exit-code: '1'

.github/workflows/daily_scan.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,25 @@ jobs:
6565
if: ${{ steps.dep_scan.outcome != 'success' }}
6666
run: less dependency-check-report.html
6767

68+
- name: Configure AWS credentials for image scan
69+
uses: aws-actions/configure-aws-credentials@v4
70+
with:
71+
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE_ARN }}
72+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
73+
74+
- name: Login to Public ECR
75+
uses: docker/login-action@v3
76+
with:
77+
registry: public.ecr.aws
78+
6879
- name: Perform high image scan
6980
if: always()
7081
id: high_scan
7182
uses: ./.github/actions/image_scan
7283
with:
7384
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-dotnet:v1.9.0"
7485
severity: 'CRITICAL,HIGH'
86+
logout: 'false'
7587

7688
- name: Perform low image scan
7789
if: always()
@@ -80,6 +92,7 @@ jobs:
8092
with:
8193
image-ref: "public.ecr.aws/aws-observability/adot-autoinstrumentation-dotnet:v1.9.0"
8294
severity: 'MEDIUM,LOW,UNKNOWN'
95+
logout: 'false'
8396

8497
- name: Configure AWS Credentials for emitting metrics
8598
if: always()

0 commit comments

Comments
 (0)