-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (64 loc) · 2.2 KB
/
auto-run.yml
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
name: auto-run
on:
push:
paths:
- 'algos/**/*'
branches:
- main
workflow_dispatch:
jobs:
list-algos:
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' && !contains(github.event.head_commit.message, 'skipci') || github.event_name == 'workflow_dispatch' }}
outputs:
algo_list: ${{ steps.set_algo_list.outputs.algo_list }}
runner: ${{ steps.select_runner.outputs.runner }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Find changed algorithms
if: ${{ github.event_name == 'push' }}
id: find_changed_files
uses: tj-actions/changed-files@v34
with:
files: "algos/**/*"
json: "true"
- name: Set algo list
id: set_algo_list
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
all_algos=$(find algos -type f -name main.sh | cut -d/ -f2)
else
# Extract only the unique directory names where changes have occurred
changed_dirs=$(echo "${{ steps.find_changed_files.outputs.all_changed_files }}" | jq -rc '.[]' | cut -d/ -f1,2 | uniq)
all_algos=""
for DIR in $changed_dirs; do
if [ -f "${DIR}/main.sh" ]; then
all_algos+=$(echo "${DIR}" | cut -d/ -f2)" "
fi
done
fi
algo_list="["
for ALGO in $all_algos; do
AUTORUN=$(cat .github/workflows/build-config.json | jq ".${ALGO}.autoRun")
[ "$AUTORUN" == "null" ] && AUTORUN=$(cat .github/workflows/build-config.json | jq ".default.autoRun")
if [ "$AUTORUN" == "true" ]; then
algo_list+="\"${ALGO}\","
fi
done
algo_list=$(echo "$algo_list" | sed 's/,$//')
algo_list+="]"
echo "algo_list=${algo_list}"
echo "algo_list=${algo_list}" >> $GITHUB_OUTPUT
- name: Select runner
id: select_runner
run: |
echo "runner=\"ubuntu-22.04\"" >> $GITHUB_OUTPUT
build-apps:
needs: list-algos
uses: ./.github/workflows/run-algos.yml
with:
algo_list: ${{ needs.list-algos.outputs.algo_list }}
runner: ${{ needs.list-algos.outputs.runner }}
secrets: inherit