Repository navigation
49 lines (45 loc) · 1.55 KB
/
Copy pathci-compose.yml
File metadata and controls
49 lines (45 loc) · 1.55 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
name: compose
on:
push:
branches:
- master
paths:
- ".github/workflows/ci-compose.yml"
- "**compose*.yml"
- "**compose*.yaml"
pull_request:
paths:
- ".github/workflows/ci-compose.yml"
- "**compose*.yml"
- "**compose*.yaml"
jobs:
validate:
name: Validate compose files
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: validate tracked compose files
run: |
set -euo pipefail
n=0
# null-delimited to stay safe with unusual filenames; exclude this
# workflow (its name contains "compose") and vendored compose files.
# filenames are not echoed as workflow commands to avoid log-command injection
while IFS= read -r -d '' f; do
docker compose -f "$f" config --quiet
n=$((n + 1))
done < <(git ls-files -z '*compose*.yml' '*compose*.yaml' ':!:*/vendor/*' ':!:.github/*' ':!:compose-e2e-coverage.yml')
# compose-e2e-coverage.yml is an overlay: its services carry no image and no build
# context of their own, so it parses only merged onto the base it extends, which is
# the only way anything runs it
docker compose -f compose-e2e-test.yml -f compose-e2e-coverage.yml config --quiet
n=$((n + 1))
if [ "$n" -eq 0 ]; then
echo "no compose files found" >&2
exit 1
fi
echo "validated $n compose file(s)"