6
6
- main
7
7
- master
8
8
- develop
9
+ - feature/mpu6050
9
10
paths-ignore :
10
11
- " **/*.md"
11
12
push :
12
13
branches :
13
14
- main
14
15
- master
15
16
- develop
17
+ - feature/mpu6050
16
18
paths-ignore :
17
19
- " **/*.md"
18
20
31
33
steps :
32
34
- uses : actions/checkout@v4
33
35
36
+ # We will skip the build if there are no changes in the examples or src folder
37
+ - name : Get changed files
38
+ id : changed-files
39
+ uses : tj-actions/changed-files@v44
40
+ with :
41
+ files : |
42
+ "examples/**/*.ino"
43
+ "src/**/*"
44
+
45
+ - name : Extract device name
46
+ id : device
47
+ run : |
48
+ # get 2nd element from the example path as lowercase
49
+ DEVICE=$(echo "${{ matrix.example }}" | cut -d'/' -f2 | tr '[:upper:]' '[:lower:]')
50
+ echo "device=$DEVICE" >> "$GITHUB_OUTPUT"
51
+
52
+ - name : Check if the build is necessary
53
+ id : should-build
54
+ run : |
55
+ if [ -z "${{ steps.changed-files.outputs.all_modified_files }}" ]; then
56
+ echo "No changes in the examples or src folder. Skipping the build."
57
+ echo "should_build=false" >> "$GITHUB_OUTPUT"
58
+ else
59
+ # todo: check device name with changed files
60
+ echo "Changes detected in the examples or src folder. Proceeding with the build."
61
+ echo "should_build=true" >> "$GITHUB_OUTPUT"
62
+ fi
63
+
34
64
- name : Cache pip
65
+ if : ${{ steps.should-build.outputs.should_build == 'true' }}
35
66
uses : actions/cache@v4
36
67
with :
37
68
path : ~/.cache/pip
40
71
${{ runner.os }}-pip-
41
72
42
73
- name : Cache PlatformIO
74
+ if : ${{ steps.should-build.outputs.should_build == 'true' }}
43
75
uses : actions/cache@v4
44
76
with :
45
77
path : |
@@ -50,18 +82,21 @@ jobs:
50
82
${{ runner.os }}-pio-
51
83
52
84
- name : Set up Python
85
+ if : ${{ steps.should-build.outputs.should_build == 'true' }}
53
86
uses : actions/setup-python@v5
54
87
with :
55
88
python-version : " 3.9"
56
89
57
90
- name : Install PlatformIO
91
+ if : ${{ steps.should-build.outputs.should_build == 'true' }}
58
92
run : |
59
93
python -m pip install --upgrade pip
60
94
pip install --upgrade platformio
61
95
pio upgrade --dev
62
96
pio pkg update --global
63
97
64
98
- name : Build example
99
+ if : ${{ steps.should-build.outputs.should_build == 'true' }}
65
100
run : |
66
101
pio ci --lib="." --board=${{ join(matrix.boards, ' --board=') }}
67
102
env :
0 commit comments