Skip to content

Commit b662b48

Browse files
Enhance CI workflow with Docker Scout (#377)
Signed-off-by: Mathieu Benoit <[email protected]>
1 parent c938944 commit b662b48

File tree

1 file changed

+67
-11
lines changed

1 file changed

+67
-11
lines changed

.github/workflows/ci.yaml

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ on:
77
- main
88
permissions:
99
contents: read
10+
pull-requests: write
1011
jobs:
1112
test:
1213
runs-on: ubuntu-latest
1314
steps:
14-
- name: Checkout
15-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
15+
- name: checkout code in current PR branch
16+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
1617
with:
1718
fetch-depth: 0
1819
- name: Fetch all tags
1920
run: git fetch --force --tags
2021
- name: Set up Go
21-
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
22+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
2223
with:
2324
go-version-file: 'go.mod'
2425
- name: Run Go Vet
@@ -35,17 +36,72 @@ jobs:
3536
run: go install github.com/google/addlicense@dc31ac9ffcca99c9457226366135701794b128c0
3637
- name: Check licenses
3738
run: addlicense -l apache -check -v -ignore '**/*.yaml' -c 'The Score Authors' ./cmd ./internal/
38-
- name: Build docker image
39-
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
39+
- name: Set up Docker
40+
uses: docker/setup-docker-action@v4
41+
with:
42+
daemon-config: |
43+
{
44+
"debug": true,
45+
"features": {
46+
"containerd-snapshotter": true
47+
}
48+
}
49+
- name: docker login
50+
uses: docker/login-action@v3
51+
with:
52+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
53+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
- name: Build container image from PR branch
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
push: false
61+
load: true
62+
cache-from: type=gha
63+
cache-to: type=gha,mode=max
64+
provenance: mode=max
65+
sbom: true
66+
tags: score-compose:pr-${{ github.event.number }}
67+
- name: docker images
68+
run: |
69+
docker images
70+
- name: checkout code in main branch
71+
uses: actions/checkout@v6
72+
with:
73+
ref: main
74+
- name: Build container image from main branch
75+
uses: docker/build-push-action@v6
4076
with:
4177
context: .
4278
push: false
4379
load: true
44-
tags: score-compose:test
45-
build-args: |
46-
"VERSION=test"
47-
- name: Test docker image
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
provenance: mode=max
83+
sbom: true
84+
tags: score-compose:main
85+
- name: docker images
86+
run: |
87+
docker images
88+
- name: Docker Scout Comparison between main branch and current PR branch
89+
uses: docker/scout-action@v1
90+
with:
91+
command: compare
92+
image: local://score-compose:pr-${{ github.event.number }}
93+
to: local://score-compose:main
94+
write-comment: true
95+
github-token: ${{ secrets.GITHUB_TOKEN }}
96+
organization: ${{ secrets.DOCKER_HUB_ORG }}
97+
- name: Test docker image built in PR branch
4898
run: |
49-
docker run --rm score-compose:test --version
50-
docker run -v .:/score-compose --rm score-compose:test init
99+
docker run --rm score-compose:pr-${{ github.event.number }} --version
100+
docker run -v .:/score-compose --rm score-compose:pr-${{ github.event.number }} init
51101
cat score.yaml
102+
103+
104+
105+
106+
107+

0 commit comments

Comments
 (0)