-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
29 lines (25 loc) · 1.29 KB
/
action.yaml
File metadata and controls
29 lines (25 loc) · 1.29 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
name: 'Policy Matrix'
description: 'Retrieves the changed policies'
outputs:
policy_working_dirs:
description: 'The directories of the changed policies'
value: ${{ steps.calculate-policy-dirs.outputs.policy_working_dirs }}
runs:
using: 'composite'
steps:
- name: calculate which policies need a CI job
id: calculate-policy-dirs
shell: bash
run: |
git remote -v
policies_working_dirs=($(find policies -maxdepth 2 -name Makefile -exec dirname '{}' \;))
if [ "${{github.event_name}}" == "pull_request" ]; then
# list only changes of files in `policies/`:
git_files="$(git diff --no-color --find-renames --find-copies --name-only origin/${{ github.base_ref }} ${{ github.sha }} -- policies)"
# build policy_working_dirs:
policies_working_dirs=($(echo "$git_files" | cut -d/ -f1,2 ))
fi
declare -p policies_working_dirs
policy_working_dirs=$(jq --compact-output --null-input '$ARGS.positional | map(select(. != "policies/Cargo.lock" and . != "policies/Cargo.toml" and . != "policies/go.mod" and . != "policies/go.sum")) | unique' --args -- "${policies_working_dirs[@]}")
echo "policy_working_dirs=$policy_working_dirs"
echo "policy_working_dirs=$policy_working_dirs" >> $GITHUB_OUTPUT