Skip to content

Commit 7ed9990

Browse files
author
Sam Morris
committed
modularize workflows
1 parent 293d9fe commit 7ed9990

File tree

4 files changed

+48
-18
lines changed

4 files changed

+48
-18
lines changed

.github/workflows/build-and-push.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ on:
1212

1313
env:
1414
IMAGE_NAME: samanthamorris684/catbot
15-
# Change this from latest
16-
COMPARE_TAG: latest
1715
USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
1816
PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
1917

@@ -34,19 +32,6 @@ jobs:
3432
run: |
3533
docker build -t $IMAGE_NAME:${{ inputs.IMAGE_TAG }} .
3634
docker push $IMAGE_NAME:${{ inputs.IMAGE_TAG }}
37-
38-
- name: Docker Scout
39-
id: docker-scout
40-
if: ${{ github.event_name == 'pull_request' }}
41-
uses: docker/scout-action@v1
42-
with:
43-
command: compare
44-
image: $IMAGE_NAME:${{ inputs.IMAGE_TAG }}
45-
to: ${{ env.IMAGE_NAME }}:${{ env.COMPARE_TAG }}
46-
ignore-unchanged: true
47-
only-severities: critical,high
48-
write-comment: true
49-
github-token: ${{ secrets.GITHUB_TOKEN }} # to be able to write the comment
5035
5136
5237

.github/workflows/feature-branch.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ jobs:
1010
with:
1111
IMAGE_TAG: $GITHUB_REF_NAME
1212
secrets:
13-
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
14-
15-
13+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Pull request workflow
2+
3+
on:
4+
pull_request
5+
6+
jobs:
7+
scout:
8+
uses: ./.github/workflows/scout.yml
9+
with:
10+
IMAGE_TAG: $GITHUB_REF_NAME

.github/workflows/scout.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Security workflow
2+
on:
3+
workflow_call:
4+
inputs:
5+
IMAGE_TAG:
6+
required: true
7+
type: string
8+
9+
env:
10+
REGISTRY: samanthamorris684
11+
IMAGE_NAME: catbot
12+
COMPARE_TAG: latest
13+
USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
14+
PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
15+
16+
jobs:
17+
scout:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Login to registry
21+
uses: docker/login-action@v2.1.0
22+
with:
23+
registry: ${{ env.REGISTRY }}
24+
username: ${{ env.USERNAME }}
25+
password: ${{ env.PASSWORD }}
26+
27+
- name: Docker Scout
28+
id: docker-scout
29+
uses: docker/scout-action@v1
30+
with:
31+
command: compare
32+
image: $IMAGE_NAME:${{ inputs.IMAGE_TAG }}
33+
to: ${{ env.IMAGE_NAME }}:${{ env.COMPARE_TAG }}
34+
ignore-unchanged: true
35+
only-severities: critical,high
36+
write-comment: true
37+
github-token: ${{ secrets.GITHUB_TOKEN }} # to be able to write the comment

0 commit comments

Comments
 (0)