Skip to content

Commit f192422

Browse files
authored
Merge pull request #14 from cupofpython/scout
add scout job
2 parents cbc46a5 + 0d0393b commit f192422

File tree

6 files changed

+68
-24
lines changed

6 files changed

+68
-24
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ on:
1111
type: string
1212

1313
env:
14-
IMAGE_NAME: samanthamorris684/catbot
14+
REGISTRY: samanthamorris684
15+
IMAGE_NAME: catbot
1516
USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
1617
PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }}
1718

@@ -30,9 +31,8 @@ jobs:
3031

3132
- name: Build and push the Docker image
3233
run: |
33-
docker build -t $IMAGE_NAME:${{ inputs.IMAGE_TAG }} .
34-
docker push $IMAGE_NAME:${{ inputs.IMAGE_TAG }}
35-
34+
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }} .
35+
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }}
3636
3737
3838

.github/workflows/deploy-to-eks.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
type: string
1616

1717
env:
18-
IMAGE_NAME: samanthamorris684/catbot
18+
REGISTRY: samanthamorris684
19+
IMAGE_NAME: catbot
1920
EKS_CLUSTER_NAME: catbot-cluster
2021
NAMESPACE: cat-chatbot
2122

@@ -36,5 +37,5 @@ jobs:
3637

3738
- name: Deploy to EKS
3839
run: |
39-
kubectl set image deployment/server server=${{ env.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }} -n ${{ env.NAMESPACE }}
40+
kubectl set image deployment/server server=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }} -n ${{ env.NAMESPACE }}
4041
kubectl rollout status deployment/server -n ${{ env.NAMESPACE }}

.github/workflows/feature-branch.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/main-branch.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
branches: main
66

7-
env:
8-
IMAGE_NAME: samanthamorris684/catbot
9-
107
jobs:
118
build-and-push-image:
129
uses: ./.github/workflows/build-and-push.yml
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pull request workflow
2+
3+
on:
4+
pull_request
5+
6+
jobs:
7+
build-and-push-image:
8+
uses: ./.github/workflows/build-and-push.yml
9+
with:
10+
IMAGE_TAG: pr-${{ github.event.number }}
11+
secrets:
12+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
13+
scout:
14+
permissions:
15+
pull-requests: write
16+
needs: build-and-push-image
17+
uses: ./.github/workflows/scout.yml
18+
with:
19+
IMAGE_TAG: pr-${{ github.event.number }}
20+
secrets:
21+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

.github/workflows/scout.yml

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

0 commit comments

Comments
 (0)