Skip to content

Commit dc888d1

Browse files
Create compile-arduino.yml
1 parent edfe8b9 commit dc888d1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/compile-arduino.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Compile Arduino Sketches
2+
3+
on:
4+
push:
5+
paths:
6+
- 'sketches/**.ino'
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
compile:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Setup Arduino CLI
18+
uses: arduino/setup-arduino-cli@v1
19+
20+
- name: Install Arduino Core
21+
run: |
22+
arduino-cli core update-index
23+
arduino-cli core install arduino:avr
24+
25+
- name: Find and compile sketches
26+
run: |
27+
mkdir -p builds
28+
for sketch in sketches/*.ino; do
29+
if [ -f "$sketch" ]; then
30+
echo "Compiling $sketch"
31+
sketch_name=$(basename "$sketch" .ino)
32+
sketch_dir=$(dirname "$sketch")
33+
34+
# Compile the sketch
35+
arduino-cli compile --fqbn arduino:avr:uno "$sketch" --output-dir "builds/$sketch_name"
36+
37+
# Add timestamp to build info
38+
echo "Compiled on $(date)" > "builds/$sketch_name/build_info.txt"
39+
fi
40+
done
41+
42+
- name: Commit compiled files
43+
run: |
44+
git config --local user.email "[email protected]"
45+
git config --local user.name "GitHub Actions"
46+
git add builds/
47+
git commit -m "Add compiled sketches [skip ci]" || echo "No changes to commit"
48+
git push

0 commit comments

Comments
 (0)