-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
176 lines (152 loc) · 5.04 KB
/
Copy pathTaskfile.yml
File metadata and controls
176 lines (152 loc) · 5.04 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
version: '3'
env:
JQ: docker run --rm -i ghcr.io/jqlang/jq:1.8.1
HADOLINT_IMAGE: ghcr.io/hadolint/hadolint:v2.14.0
ACTIONLINT_IMAGE: rhysd/actionlint:1.7.12
ZIZMOR_IMAGE: ghcr.io/zizmorcore/zizmor:1.25.2
PINACT_IMAGE: ghcr.io/toshy/docker-pinact:4.1.0
tasks:
default:
cmds:
- task --list
# nektos/act
act:push:
desc: Test release
cmds:
- act push {{.CLI_ARGS}}
act:push:version:
desc: Test release for specific version
summary: |
Example:
task act:push:version pv="8.5.2"
vars:
PHP_VERSIONS: '{{ .pv | default "8.5.2"}}'
cmds:
- act push --input version={{.PHP_VERSIONS}}
act:job:prepare:
desc: Act test "prepare" job
cmds:
- act -j prepare {{.CLI_ARGS}}
act:job:build:
desc: Act test "build" job
cmds:
- act -j build {{.CLI_ARGS}}
act:job:merge:
desc: Act test "merge" job
cmds:
- act -j merge {{.CLI_ARGS}}
# buildx bake
bake:
desc: Bake
vars:
PHP_VERSIONS: '{{ .pv | default "8.2.33,8.3.32,8.4.23,8.5.8"}}'
cmds:
- PHP_VERSIONS={{.PHP_VERSIONS}} docker buildx bake --set *.platform=linux/amd64
bake:print:
desc: Bake print options without building
vars:
PHP_VERSIONS: '{{ .pv | default "8.2.33,8.3.32,8.4.23,8.5.8"}}'
cmds:
- PHP_VERSIONS={{.PHP_VERSIONS}} docker buildx bake --print | $JQ
# zensical
docs:
desc: Zensical build
cmds:
- docker run --rm -it -v $(pwd):/docs -w /docs docker.io/zensical/zensical:0.0 build --clean
docs:live:
desc: Zensical development server
vars:
PORT: '{{.p | default "8001"}}'
cmds:
- docker run --rm -it -p {{.PORT}}:8000 -v $(pwd):/docs -w /docs docker.io/zensical/zensical:0.0 serve --dev-addr 0.0.0.0:8000
# trivy
trivy:
desc: Trivy from local build
vars:
TRIVY_VERSION: '{{ .tv | default "latest" }}'
PHP_BASE: '{{ .pv | default "8.5.2-fpm-trixie"}}'
TARGET: '{{ .t | default "ffmpeg" }}'
cmds:
- |
docker build \
--build-context php-base=docker-image://php:{{.PHP_BASE}} \
--target {{.TARGET}} \
-t toshy/trivy:{{.PHP_BASE}} .
- |
docker run --rm --pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy:{{.TRIVY_VERSION}} image \
--ignore-unfixed --severity CRITICAL,HIGH --exit-code 1 \
toshy/trivy:{{.PHP_BASE}}
trivy:remote:
desc: Trivy scan remote image
vars:
TRIVY_VERSION: '{{ .tv | default "latest" }}'
IMAGE: '{{ .t | default "ghcr.io/toshy/php:8.3-fpm-trixie-ffmpeg" }}'
cmds:
- |
docker pull {{.IMAGE}}
- |
docker run --rm --pull=always \
-v /var/run/docker.sock:/var/run/docker.sock \
aquasec/trivy:{{.TRIVY_VERSION}} image \
--ignore-unfixed --severity CRITICAL --exit-code 1 \
{{.IMAGE}}
# Linting
hadolint:
desc: Lint all Dockerfiles
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo {{.HADOLINT_IMAGE}} hadolint /repo/Dockerfile
actionlint:
desc: Lint GitHub Actions workflows in .github/workflows
silent: true
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo "{{.ACTIONLINT_IMAGE}}" -color
zizmor:
desc: Audit GitHub Actions workflows for security issues in .github/workflows
silent: true
cmds:
- docker run --rm -v "{{.ROOT_DIR}}:/repo" -w /repo "{{.ZIZMOR_IMAGE}}" --color=always --collect=workflows .
pinact:
desc: Validate GitHub Actions are pinned to commit SHAs in .github/workflows
summary: |
Check pinned GitHub Actions against commit SHAs in .github/workflows.
Usage:
- task pinact TOKEN=github_pat_...
If no "TOKEN" environment variable is passed, you might experience rate limiting.
See https://github.com/suzuki-shunsuke/pinact#github-access-token.
silent: true
vars:
TOKEN: '{{.t | default ""}}'
cmds:
- |
if [ ! -d "{{.ROOT_DIR}}/.github/workflows" ]; then
printf "\033[33m[pinact]\033[0m no .github/workflows directory found\n"
exit 0
fi
docker run --rm \
-v "{{.ROOT_DIR}}:/repo" \
-e PINACT_GITHUB_TOKEN="{{.TOKEN}}" \
"{{.PINACT_IMAGE}}" run --diff
pinact:fix:
desc: Pin GitHub Actions to commit SHAs in-place in .github/workflows
summary: |
Check pinned GitHub Actions against commit SHAs in .github/workflows and fixes them.
Usage:
- task pinact:fix TOKEN=github_pat_...
If no "TOKEN" environment variable is passed, you might experience rate limiting.
See https://github.com/suzuki-shunsuke/pinact#github-access-token.
silent: true
vars:
TOKEN: '{{.t | default ""}}'
cmds:
- |
if [ ! -d "{{.ROOT_DIR}}/.github/workflows" ]; then
printf "\033[33m[pinact]\033[0m no .github/workflows directory found\n"
exit 0
fi
docker run --rm \
-v "{{.ROOT_DIR}}:/repo" \
-u "${UID}:${GID}" \
-e PINACT_GITHUB_TOKEN="{{.TOKEN}}" \
"{{.PINACT_IMAGE}}" run --fix