Repository navigation
104 lines (89 loc) · 2.71 KB
/
Copy pathdocker.yml
File metadata and controls
104 lines (89 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Docker
on:
push:
branches: [main]
paths:
- "Dockerfile"
- ".dockerignore"
- "requirements.txt"
- "pyproject.toml"
- "src/**"
- ".github/workflows/docker.yml"
pull_request:
paths:
- "Dockerfile"
- ".dockerignore"
- "requirements.txt"
- "pyproject.toml"
- "src/**"
- ".github/workflows/docker.yml"
workflow_dispatch:
permissions:
contents: read
security-events: write
concurrency:
group: docker-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and verify image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
# Images are loaded into the local daemon, never pushed. Publishing to
# GHCR happens only on version tags, in release.yml.
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
tags: instagram-username-finder:ci
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run --version
run: docker run --rm instagram-username-finder:ci --version
- name: Run --help
run: docker run --rm instagram-username-finder:ci --help
- name: Run scan --help
run: docker run --rm instagram-username-finder:ci scan --help
- name: Verify the container does not run as root
run: |
uid="$(docker run --rm --entrypoint id instagram-username-finder:ci -u)"
echo "container uid: $uid"
test "$uid" != "0"
- name: Verify state and results are writable in the data volume
run: |
mkdir -p "$RUNNER_TEMP/data"
docker run --rm -v "$RUNNER_TEMP/data:/app/data" \
instagram-username-finder:ci \
scan --help > /dev/null
scan:
name: Vulnerability scan
runs-on: ubuntu-latest
needs: build
# Advisory only: a new CVE in a base image should not block a pull request.
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Build image for scanning
uses: docker/build-push-action@v6
with:
context: .
load: true
push: false
tags: instagram-username-finder:scan
- name: Run Trivy
uses: aquasecurity/trivy-action@v0.36.0
with:
image-ref: instagram-username-finder:scan
format: sarif
output: trivy-results.sarif
severity: CRITICAL,HIGH
ignore-unfixed: true
- name: Upload results to the security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: trivy-results.sarif