Skip to content

Commit bf67543

Browse files
authored
push runs only changed recipes, while both weekly schedule and manual workflow_dispatch always run all (#695)
1 parent aab16ce commit bf67543

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

.github/workflows/bootstrap.yml

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,16 @@ concurrency:
1313
cancel-in-progress: true
1414

1515
on:
16+
# Regenerate workflows when supported recipe templates change on master.
1617
push:
1718
branches: [master]
1819
paths:
19-
- .github/workflows/bootstrap.yml
20-
- .github/workflows/create_workflows.py
21-
- neurodocker/**
22-
23-
# Uses the cron schedule for github actions
24-
#
25-
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#scheduled-events
26-
#
27-
# ┌───────────── minute (0 - 59)
28-
# │ ┌───────────── hour (0 - 23)
29-
# │ │ ┌───────────── day of the month (1 - 31)
30-
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
31-
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
32-
# │ │ │ │ │
33-
# │ │ │ │ │
34-
# │ │ │ │ │
35-
# * * * * *
36-
20+
- neurodocker/templates/*.yaml
21+
# Runs weekly on Sunday at 00:00 UTC.
3722
schedule:
38-
- cron: 0 0 1,15 * *
39-
40-
# Allows you to run this workflow manually from the Actions tab
23+
- cron: '0 0 * * 0'
24+
# Allows you to run this workflow manually from the Actions tab
4125
workflow_dispatch:
42-
inputs:
43-
software_name:
44-
description: software to test
45-
required: true
46-
default: all
4726

4827
permissions:
4928
contents: write
@@ -56,6 +35,7 @@ jobs:
5635
- uses: actions/checkout@v6
5736
with:
5837
token: ${{ secrets.CI_FLOW }}
38+
fetch-depth: 0
5939

6040
- name: Set up Python
6141
uses: actions/setup-python@v6
@@ -67,20 +47,45 @@ jobs:
6747

6848
- name: Create workflows
6949
run: |
70-
software_name=${{ inputs.software_name }}
71-
if [ -z "$software_name" ]; then
72-
software_name="all"
50+
if [ "${{ github.event_name }}" = "push" ]; then
51+
echo "detecting changed recipe templates"
52+
changed_recipes=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'neurodocker/templates/*.yaml' \
53+
| sed -E 's#^neurodocker/templates/##; s#\.yaml$##' \
54+
| sort -u)
55+
if [ -z "$changed_recipes" ]; then
56+
echo "no recipe template changes detected"
57+
exit 0
58+
fi
7359
fi
74-
if [ "$software_name" = "all" ]; then
75-
echo "testing all software"
60+
61+
git checkout -b test_docker_build
62+
63+
if [ "${{ github.event_name }}" = "push" ]; then
64+
echo "testing changed recipes:"
65+
echo "$changed_recipes"
66+
for recipe in $changed_recipes; do
67+
case "$recipe" in
68+
afni|ants|bids_validator|cat12|convert3d|dcm2niix|freesurfer|fsl|jq|matlabmcr|miniconda|mricron|mrtrix3|spm12)
69+
python .github/workflows/create_workflows.py --software_name "${recipe}"
70+
;;
71+
*)
72+
echo "skipping unsupported recipe: ${recipe}"
73+
;;
74+
esac
75+
done
7676
else
77-
echo "testing ${software_name}"
77+
software_name="all"
78+
echo "testing all software"
79+
python .github/workflows/create_workflows.py --software_name "${software_name}"
7880
fi
79-
git checkout -b test_docker_build
80-
python .github/workflows/create_workflows.py --software_name ${software_name}
81+
8182
ls -l .github/workflows
8283
git add .
84+
if git diff --cached --quiet; then
85+
echo "no workflow updates to commit"
86+
exit 0
87+
fi
8388
git config --global user.email "no-reply@repronim.org"
8489
git config --global user.name "Repronim neurodocker bot"
85-
git commit -am "added new workflows"
90+
git commit -m "added new workflows"
8691
git push origin --force test_docker_build

0 commit comments

Comments
 (0)