Update main.sh #51
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |