-
Notifications
You must be signed in to change notification settings - Fork 82
46 lines (43 loc) · 1.72 KB
/
reusable_get_changed_plugins.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
# This is a reusable workflow used by main CI
on:
workflow_call:
outputs:
changed-plugins:
description: "A json-encoded array with the names of plugins to be used by the CI"
value: ${{ jobs.get-values.outputs.changed-plugins }}
jobs:
get-values:
runs-on: ubuntu-latest
outputs:
changed-plugins: ${{ steps.set-changed-plugins.outputs.changed-plugins }}
steps:
- name: Checkout rules
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get changed files
id: changed-plugins
if: github.event_name == 'pull_request'
uses: Ana06/get-changed-files@25f79e676e7ea1868813e21465014798211fad8c # v2.3.0
with:
format: space-delimited
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get changed plugins
id: set-changed-plugins
run: |
# if we skip changed-plugins because we're not in a pull-request,
# then we consider all the rules contained in the repo
all_files="${{ steps.changed-plugins.outputs.all }}"
values=""
if [ -z "$all_files" ]; then
values=$(ls plugins)
else
for changed_file in $all_files; do
if [[ ${changed_file} =~ ^plugins/.* ]]; then
plugindir=$(echo ${changed_file} | sed -e 's/^plugins//' | sed -E 's_(/[^/]+).*_\1_')
pluginname="${plugindir:1}"
if [[ ! $values =~ "$pluginname" ]]; then
values="${values}$pluginname"$'\n'
fi
fi
done
fi
echo "changed-plugins=$(echo "${values}" | jq -R -s -c 'split("\n")' | jq -c 'map(select(length > 0))')" >> $GITHUB_OUTPUT