-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (74 loc) · 2.36 KB
/
containers.build.yaml
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
name: "Containers: Test-and-Build"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'apps/**'
- 'dev/**'
- 'base/**'
- ".github/workflows/containers.build.yaml"
pull_request:
paths:
- 'apps/**'
- 'dev/**'
- 'base/**'
- ".github/workflows/containers.build.yaml"
# Detect which folders in project-root (which contain the containers) contain changes
jobs:
changes:
name: Get changes
runs-on: ubuntu-latest
outputs:
matrix: "{\"container\": ${containers} }"
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: json
filters: |
changed:
- 'apps/**'
- 'dev/**'
- 'base/**'
- run: echo '${{ toJson(steps.filter.outputs) }}' > changes.json
- id: reduce
run: |
CONTAINERS=$(jq --raw-output '.changed_files | fromjson | .[] |= sub("(?<filepath>(?<first_directory>(?<root1>[/]?)[^/]+/)(?<second_directory>(?<root2>[/]?)[^/]+)(?<extra_paths>.+))"; "\(.second_directory)") | unique' changes.json)
echo "containers=${CONTAINERS}" >> "$GITHUB_ENV"
hadolint:
name: Run hadolint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- name: hadolint
uses: reviewdog/action-hadolint@f7d29ec6dd89022747bd18b5a151b62ac2f1555e # v1.36.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
filter_mode: diff_context
fail_on_error: true
build:
permissions:
actions: read # for detecting the Github Actions environment.
id-token: write # for creating OIDC tokens for signing.
packages: write # for uploading attestations.
name: Build
runs-on: ubuntu-latest
needs:
- hadolint
- changes
strategy:
matrix: ${{ fromJson(needs.changes.outputs.matrix) }}
fail-fast: false
if: "!contains(github.event.head_commit.message, '[ci-skip]')"
steps:
- name: Checkout
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
# NOTE
# many of this code was copied from the great workflow of truechats/containers
# https://github.com/truecharts/containers/blob/master/.github/workflows/containers.build.yaml