@@ -33,10 +33,11 @@ jobs:
33
33
runs-on : ubuntu-latest
34
34
35
35
outputs :
36
- database : ${{ steps.changed.outputs.database_any_changed }}
37
- docker : ${{ steps.changed.outputs.docker_any_changed }}
38
- elixir : ${{ steps.changed.outputs.elixir_any_changed }}
39
- helm : ${{ steps.changed.outputs.helm_any_changed }}
36
+ database : ${{ steps.changed.outputs.database }}
37
+ docker : ${{ steps.changed.outputs.docker }}
38
+ documentation : ${{ steps.changed.outputs.documentation }}
39
+ elixir : ${{ steps.changed.outputs.elixir }}
40
+ helm : ${{ steps.changed.outputs.helm }}
40
41
41
42
steps :
42
43
- name : Checkout
@@ -46,26 +47,37 @@ jobs:
46
47
47
48
- id : changed
48
49
name : Get Changed Files
49
- uses : tj-actions/changed-files@v43
50
- with :
51
- files_yaml : |
52
- database:
53
- - '.github/workflows/ci.yaml'
54
- - 'priv/*repo/**'
55
- docker:
56
- - '.github/workflows/ci.yaml'
57
- - 'Dockerfile'
58
- elixir:
59
- - '.github/workflows/ci.yaml'
60
- - 'priv/**'
61
- - '**.ex'
62
- - '**.exs'
63
- - '**.heex'
64
- helm:
65
- - '.github/workflows/ci.yaml'
66
- - '.github/workflows/staging.yaml'
67
- - '.github/workflows/production.yaml'
68
- - 'helm/**'
50
+ run : |
51
+ # Using fetch-depth 2 above, we should always be able to get the full list of changes files:
52
+ # - In a pull-request, GHA merges the PR branch into main
53
+ # - When pushed to main, we always squash merge, so there is only one new commit
54
+
55
+ CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD)
56
+
57
+ declare -A patterns
58
+ patterns["database"]=".github/workflows/ci.yaml priv/.*repo/.*"
59
+ patterns["docker"]=".github/workflows/ci.yaml Dockerfile"
60
+ patterns["documentation"]="docs/.* priv/documentation/.* .*.ex .*.md"
61
+ patterns["elixir"]=".github/workflows/ci.yaml .tool-versions priv/.* .*.ex .*.exs .*.heex"
62
+ patterns["helm"]=".github/workflows/ci.yaml .github/workflows/staging.yaml .github/workflows/production.yaml helm/.*"
63
+
64
+ for filetype in ${!patterns[@]}; do
65
+ found="false"
66
+ echo "==> Checking: $filetype"
67
+ for pattern in ${patterns[$filetype]}; do
68
+ for changed_file in $CHANGED_FILES; do
69
+ if [[ "$changed_file" =~ $pattern ]]; then
70
+ echo "====> Found change: $changed_file"
71
+ found="true"
72
+ break
73
+ fi
74
+ done
75
+ if [[ "$found" == "true" ]]; then
76
+ break
77
+ fi
78
+ done
79
+ echo "$filetype=$found" >> $GITHUB_OUTPUT
80
+ done
69
81
70
82
Credo :
71
83
if : ${{ !startsWith(github.head_ref, 'release-please--branches') && needs.Changed.outputs.elixir == 'true' }}
92
104
needs : [Changed]
93
105
runs-on : ubuntu-latest
94
106
107
+ env :
108
+ MIX_ENV : test
109
+
95
110
steps :
96
111
- name : Checkout
97
112
uses : actions/checkout@v4
@@ -128,7 +143,7 @@ jobs:
128
143
run : mix dialyzer --format github
129
144
130
145
Documentation :
131
- if : ${{ !startsWith(github.head_ref, 'release-please--branches') && needs.Changed.outputs.elixir == 'true' }}
146
+ if : ${{ !startsWith(github.head_ref, 'release-please--branches') && needs.Changed.outputs.documentation == 'true' }}
132
147
needs : [Changed]
133
148
runs-on : ubuntu-latest
134
149
@@ -209,3 +224,34 @@ jobs:
209
224
- elixir : 1.15
210
225
otp : 26
211
226
227
+ Trivy_Filesystem :
228
+ if : ${{ !startsWith(github.head_ref, 'release-please--branches') }}
229
+ name : Trivy Filesystem Scan
230
+ runs-on : ubuntu-latest
231
+
232
+ permissions :
233
+ contents : read
234
+ id-token : write
235
+ pull-requests : write
236
+
237
+ steps :
238
+ - name : Checkout
239
+ uses : actions/checkout@v4
240
+
241
+ - name : Setup Elixir
242
+ uses : stordco/actions-elixir/setup@v1
243
+ with :
244
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
245
+ hex-token : ${{ secrets.HEX_API_KEY }}
246
+ oban-fingerprint : ${{ secrets.OBAN_KEY_FINGERPRINT }}
247
+ oban-token : ${{ secrets.OBAN_LICENSE_KEY }}
248
+
249
+ - name : Trivy Scan
250
+ uses : stordco/actions-trivy@v1
251
+ with :
252
+ github-token : ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
253
+ scan-type : fs
254
+ slack-bot-token : ${{ secrets.SLACK_BOT_TOKEN }}
255
+ slack-channel-id : ${{ secrets.SLACK_SECURITY_ALERTS }}
256
+ update-db : false
257
+
0 commit comments