1- ---
2- name : ' ci '
1+ name : ' Docker ci '
2+
33on :
4- push :
5- branches :
6- - ' main'
7- pull_request :
8- branches :
9- - ' *'
10- paths-ignore :
11- - ' **.md'
12- workflow_dispatch :
4+ workflow_call :
5+ inputs :
6+ image_name :
7+ required : true
8+ type : string
9+ local_scan_tag :
10+ required : true
11+ type : string
12+ dockerfile_path :
13+ required : false
14+ type : string
15+ default : ' Dockerfile'
16+ ecr_repository :
17+ required : true
18+ type : string
1319
1420permissions :
1521 contents : ' read'
1622 issues : ' write'
1723 pull-requests : ' write'
1824
19- env :
20- IMAGE_NAME : ' actions-runner'
21- LOCAL_SCAN_TAG : ' ci-scan'
22-
2325jobs :
2426 ApplyCommonLinting :
2527 uses : ' icariohealth/.github/.github/workflows/common-linting.yml@main'
@@ -30,16 +32,15 @@ jobs:
3032 name : ' build-scan-docker-image-packer'
3133 needs :
3234 - ' hadolint_packer'
33- # - 'ApplyCommonLinting'
3435 runs-on : ' ubuntu-latest'
3536 steps :
3637 - name : ' checkout'
37- uses : ' actions/checkout@v2 '
38+ uses : ' actions/checkout@v4 '
3839
3940 - name : ' build and tag image'
4041 id : ' build-tag-image'
4142 run : |
42- docker build --file ami/Dockerfile --tag ${IMAGE_NAME} -packer:${LOCAL_SCAN_TAG } .
43+ docker build --file ami/Dockerfile --tag ${{ inputs.image_name }} -packer:${{ inputs.local_scan_tag } } .
4344
4445 - name : ' Download lacework'
4546 run : |
4849
4950 - name : ' Scan the image'
5051 run : |
51- ./lw_scanner image evaluate --access-token ${{secrets.LW_ACCESS_TOKEN}} --account-name "icario" --pretty -w ${IMAGE_NAME} -packer:${LOCAL_SCAN_TAG }
52+ ./lw_scanner image evaluate --access-token ${{secrets.LW_ACCESS_TOKEN}} --account-name "icario" --pretty -w ${{ inputs.image_name }} -packer:${{ inputs.local_scan_tag } }
5253
5354 push_docker_image_packer :
5455 name : ' push-image-packer'
5960 runs-on : ' ubuntu-latest'
6061 steps :
6162 - name : ' checkout'
62- uses : ' actions/checkout@v2 '
63-
63+ uses : ' actions/checkout@v4 '
64+
6465 - name : ' configure aws credentials'
6566 uses : ' aws-actions/configure-aws-credentials@v1.5.5'
6667 with :
@@ -77,14 +78,14 @@ jobs:
7778 with :
7879 install : true
7980
80- - name : ' Login to Amazon ECR'
81- id : ' login-ecr'
82- uses : ' aws-actions/amazon-ecr-login@v1'
83-
8481 - name : ' tag Image'
8582 id : ' vars'
8683 run : ' echo ::set-output name=TAG::$(cat VERSION.txt)'
8784
85+ - name : ' Login to Amazon ECR'
86+ id : ' login-ecr'
87+ uses : ' aws-actions/amazon-ecr-login@v1'
88+
8889 - name : ' build-push-image'
8990 if : " github.event_name == 'push'"
9091 id : ' push-image-ecr'
@@ -104,12 +105,12 @@ jobs:
104105 runs-on : ' ubuntu-latest'
105106 steps :
106107 - name : ' checkout'
107- uses : ' actions/checkout@v2 '
108-
108+ uses : ' actions/checkout@v4 '
109+
109110 - name : ' build and tag image'
110111 id : ' build-tag-image'
111112 run : |
112- docker build --file Dockerfile --tag ${IMAGE_NAME} :${LOCAL_SCAN_TAG } .
113+ docker build --file Dockerfile --tag ${{ inputs.image_name }} :${{ inputs.local_scan_tag } } .
113114
114115 - name : ' Download lacework'
115116 run : |
@@ -118,7 +119,7 @@ jobs:
118119
119120 - name : ' Scan the image'
120121 run : |
121- ./lw_scanner image evaluate --access-token ${{secrets.LW_ACCESS_TOKEN}} --account-name "icario" --pretty -w ${IMAGE_NAME} :${LOCAL_SCAN_TAG }
122+ ./lw_scanner image evaluate --access-token ${{secrets.LW_ACCESS_TOKEN}} --account-name "icario" --pretty -w ${{ inputs.image_name }} :${{ inputs.local_scan_tag } }
122123
123124 - name : ' configure aws credentials for inspector'
124125 uses : ' aws-actions/configure-aws-credentials@v1.5.5'
@@ -132,7 +133,7 @@ jobs:
132133 uses : ' aws-actions/vulnerability-scan-github-action-for-amazon-inspector@v1'
133134 with :
134135 artifact_type : ' container'
135- artifact_path : ' ${{ env.IMAGE_NAME }}:${{ env.LOCAL_SCAN_TAG }}'
136+ artifact_path : ' ${{ inputs.image_name }}:${{ inputs.local_scan_tag }}'
136137 display_vulnerability_findings : ' enabled'
137138
138139 - name : ' Upload Inspector artifacts'
@@ -152,8 +153,8 @@ jobs:
152153 REPORT_PATH : ' ${{ steps.inspector.outputs.inspector_scan_results_markdown }}'
153154 THRESHOLD_EXCEEDED : ' ${{ steps.inspector.outputs.vulnerability_threshold_exceeded }}'
154155 COMMENT_TITLE : ' ## Amazon Inspector results'
155- NORMAL_ARTIFACT_LABEL : ' ${{ env.IMAGE_NAME }}:${{ env.LOCAL_SCAN_TAG }}'
156- PACKER_ARTIFACT_LABEL : ' ${{ env.IMAGE_NAME }}-packer:${{ env.LOCAL_SCAN_TAG }}'
156+ NORMAL_ARTIFACT_LABEL : ' ${{ inputs.image_name }}:${{ inputs.local_scan_tag }}'
157+ PACKER_ARTIFACT_LABEL : ' ${{ inputs.image_name }}-packer:${{ inputs.local_scan_tag }}'
157158 with :
158159 github-token : ' ${{ secrets.GITHUB_TOKEN }}'
159160 script : |
@@ -305,7 +306,6 @@ jobs:
305306 if [ "${{ steps.inspector.outputs.vulnerability_threshold_exceeded }}" = "1" ]; then
306307 echo "::warning::Inspector found vulnerabilities above threshold. Review findings in the PR comment before merging."
307308 fi
308-
309309 push_docker_image :
310310 name : ' push-image'
311311 needs :
@@ -315,7 +315,7 @@ jobs:
315315 runs-on : ' ubuntu-latest'
316316 steps :
317317 - name : ' checkout'
318- uses : ' actions/checkout@v2 '
318+ uses : ' actions/checkout@v4 '
319319
320320 - name : ' configure aws credentials'
321321 uses : ' aws-actions/configure-aws-credentials@v1.5.5'
@@ -351,45 +351,3 @@ jobs:
351351 export IMAGE_TAG="${ECR_REGISTRY}/${ECR_REPOSITORY}:${{ steps.vars.outputs.TAG }}"
352352 docker build -f Dockerfile --push --no-cache --platform linux/amd64,linux/arm64,linux/arm64/v8 -t ${IMAGE_TAG} -t ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest .
353353 echo "::set-output name=IMAGE_TAG::${IMAGE_TAG}"
354-
355- hadolint_packer :
356- name : ' hadolint-packer'
357- runs-on : ' ubuntu-latest'
358- steps :
359- - name : ' Clone App Repo'
360- uses : ' actions/checkout@v2'
361-
362- - name : ' Clone Github-Actions repo'
363- uses : ' actions/checkout@v2'
364- with :
365- repository : ' icariohealth/github-actions'
366- token : ' ${{ secrets.NOVU_CI_TOKEN }}'
367- path : ' ./github-actions'
368- ref : ' main'
369-
370- - name : ' Run Hadolint'
371- uses : ' ./github-actions/hadolint'
372- env :
373- GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
374- HADOLINT_ACTION_DOCKERFILE_FOLDER : " ./ami"
375-
376- hadolint :
377- name : ' hadolint'
378- runs-on : ' ubuntu-latest'
379- steps :
380- - name : ' Clone App Repo'
381- uses : ' actions/checkout@v2'
382-
383- - name : ' Clone Github-Actions repo'
384- uses : ' actions/checkout@v2'
385- with :
386- repository : ' icariohealth/github-actions'
387- token : ' ${{ secrets.NOVU_CI_TOKEN }}'
388- path : ' ./github-actions'
389- ref : ' main'
390-
391- - name : ' Run Hadolint'
392- uses : ' ./github-actions/hadolint'
393- env :
394- GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
395- HADOLINT_ACTION_DOCKERFILE_FOLDER : " ./"
0 commit comments