Skip to content

Commit d44dc8e

Browse files
OwnerOwner
authored andcommitted
Add GitHub Action to build and scan vote, worker, and result containers
1 parent 369ebc2 commit d44dc8e

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/build-scan.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Build & Scan Containers
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
security-events: write # if need to upload SARIF or similar
14+
15+
jobs:
16+
build-and-scan:
17+
runs-on: ubuntu-latest
18+
env:
19+
REGISTRY_HOST: ghcr.io
20+
REGISTRY_NAMESPACE: myorg # change to your org/user
21+
VOTE_IMAGE: ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_NAMESPACE }}/vote:latest
22+
WORKER_IMAGE: ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_NAMESPACE }}/worker:latest
23+
RESULT_IMAGE: ${{ env.REGISTRY_HOST }}/${{ env.REGISTRY_NAMESPACE }}/result:latest
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v5
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v2
31+
32+
# Build vote
33+
- name: Build vote image
34+
uses: docker/build-push-action@v4
35+
with:
36+
context: ./vote
37+
file: ./vote/Dockerfile
38+
tags: ${{ env.VOTE_IMAGE }}
39+
push: false
40+
load: true
41+
42+
# Build worker
43+
- name: Build worker image
44+
uses: docker/build-push-action@v4
45+
with:
46+
context: ./worker
47+
file: ./worker/Dockerfile
48+
tags: ${{ env.WORKER_IMAGE }}
49+
push: false
50+
load: true
51+
52+
# Build result
53+
- name: Build result image
54+
uses: docker/build-push-action@v4
55+
with:
56+
context: ./result
57+
file: ./result/Dockerfile
58+
tags: ${{ env.RESULT_IMAGE }}
59+
push: false
60+
load: true
61+
62+
# Run scan for vote
63+
- name: Scan vote image
64+
run: |
65+
./your-cli-scanner image ${{ env.VOTE_IMAGE }} --fail-on-findings
66+
# optionally env vars, secrets, etc
67+
68+
# Run scan for worker
69+
- name: Scan worker image
70+
run: |
71+
./your-cli-scanner image ${{ env.WORKER_IMAGE }} --fail-on-findings
72+
73+
# Run scan for result
74+
- name: Scan result image
75+
run: |
76+
./your-cli-scanner image ${{ env.RESULT_IMAGE }} --fail-on-findings
77+
78+
# (Optional) push images if scans passed
79+
- name: Login to registry
80+
uses: docker/login-action@v2
81+
with:
82+
registry: ${{ env.REGISTRY_HOST }}
83+
username: ${{ secrets.REGISTRY_USER }}
84+
password: ${{ secrets.REGISTRY_TOKEN }}
85+
86+
- name: Push vote image
87+
uses: docker/build-push-action@v4
88+
with:
89+
context: ./vote
90+
file: ./vote/Dockerfile
91+
tags: ${{ env.VOTE_IMAGE }}
92+
push: true
93+
load: false
94+
95+
- name: Push worker image
96+
uses: docker/build-push-action@v4
97+
with:
98+
context: ./worker
99+
file: ./worker/Dockerfile
100+
tags: ${{ env.WORKER_IMAGE }}
101+
push: true
102+
load: false
103+
104+
- name: Push result image
105+
uses: docker/build-push-action@v4
106+
with:
107+
context: ./result
108+
file: ./result/Dockerfile
109+
tags: ${{ env.RESULT_IMAGE }}
110+
push: true
111+
load: false

0 commit comments

Comments
 (0)