Skip to content

Commit 6f5bb32

Browse files
authored
Actions v2 (#1)
Updated to github action v2 Updated the action to use the action.yml file and input parameter. Updated Readme to show new workflow syntax. Added hardware input parameter
1 parent a1f4ec2 commit 6f5bb32

File tree

4 files changed

+76
-45
lines changed

4 files changed

+76
-45
lines changed

Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
FROM hexeo/arduino-builder
22

3-
LABEL "com.github.actions.name"="Run arduino-builder"
4-
LABEL "com.github.actions.description"="Run the arduino-builder for all sketches and see if they compile"
5-
LABEL "com.github.actions.icon"="server"
6-
LABEL "com.github.actions.color"="blue"
7-
8-
LABEL "repository"="https://github.com/Legion2/arduino-builder-action"
9-
10-
ADD entrypoint.sh /entrypoint.sh
3+
COPY entrypoint.sh /entrypoint.sh
114
ENTRYPOINT ["/entrypoint.sh"]

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,31 @@ Github Action to run arduino-builder for sketches and see if they compile.
33
Used Arduino IDE version is `1.8.3`.
44

55
## Usage
6-
```
7-
action "Build examples" {
8-
uses = "Legion2/arduino-builder-action@master"
9-
env = {
10-
BOARD_NAME = "arduino:avr:leonardo"
11-
}
12-
}
6+
See [action.yml](action.yml) for comprehensive list of parameters.
7+
8+
Basic:
9+
```yaml
10+
name: Build examples
11+
on: push
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v1
17+
- name: Build all example sketches
18+
uses: Legion2/arduino-builder-action@v2.0.0
19+
with:
20+
board: "arduino:avr:leonardo"
1321
```
1422
1523
### Arguments
16-
Specified arguments override any default arguments passed to arduino-builder, with the exception of the sketch parameter.
17-
The default arguments set all mandatory parameters.
18-
Use the [Environment variables](#environment-variables) to change some of the parameters.
24+
Specified arguments override any input parameters passed to arduino-builder, with the exception of the sketch input parameter.
25+
Only use arguments if the input parameters don't provide the feature you need.
26+
See the the [action.yml](action.yml) for comprehensive list of input parameters.
1927
20-
### Environment variables
21-
* **`SKETCH_PATH`** *(optional)* : Path to a single sketch
22-
* **`SKETCH_DIRECTORY_PATH`** *(optional)* : Directory in which to search for sketches (default: `examples/`)
23-
* **`BOARD_NAME`** *(optional)* : Fully Qualified Board Name (default: `arduino:avr:uno`)
24-
* **`LIBRARIES_PATH`** *(optional)* : Folder containing Arduino libraries.
25-
Use this folder to install required 3rd-party libraries.
26-
Libraries SHOULD be installed by a parent action e.g. [Download GitHub Release](https://github.com/marketplace/actions/download-github-release) (default: `libraries/`)
28+
### Install Libraries
29+
Libraries SHOULD be installed by a previous step in the job in `libraries/`.
30+
You can use [Download GitHub Release Action](https://github.com/marketplace/actions/download-github-release) to install a library form a GitHub Release.
2731

2832
## License
2933
The Dockerfile and associated scripts and documentation in this project are released under the [Apache-2.0 License](LICENSE).

action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'Run arduino-builder'
2+
description: 'Run the arduino-builder for all sketches and see if they compile'
3+
author: 'Leon Kiefer'
4+
inputs:
5+
sketch:
6+
description: 'Path to a single sketch'
7+
required: false
8+
sketchDirectory:
9+
description: 'Directory in which to search for sketches'
10+
default: 'examples'
11+
board:
12+
description: 'Fully Qualified Board Name'
13+
default: 'arduino:avr:uno'
14+
libraries:
15+
description: |
16+
Directory containing Arduino libraries.
17+
Use this directory to install required 3rd-party libraries.
18+
default: 'libraries'
19+
hardware:
20+
description: 'Directory containing Arduino platforms'
21+
default: 'hardware'
22+
runs:
23+
using: 'docker'
24+
image: 'Dockerfile'
25+
branding:
26+
icon: 'server'
27+
color: 'blue'

entrypoint.sh

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,44 @@
11
#!/bin/sh
22
set -e
33

4-
if [ -z "$BOARD_NAME" ]; then
5-
BOARD_NAME="arduino:avr:uno"
4+
BUILDER_PATH="/opt/arduino"
5+
LIBRARIES_PATH="$BUILDER_PATH/libraries:$GITHUB_WORKSPACE/../"
6+
7+
SKETCH_PATH="$INPUT_SKETCH"
8+
BOARD_NAME="$INPUT_BOARD"
9+
SKETCH_DIRECTORY_PATH="$INPUT_SKETCHDIRECTORY"
10+
11+
if [ -d "$INPUT_LIBRARIES" ]; then
12+
LIBRARIES_PATH="$LIBRARIES_PATH:$INPUT_LIBRARIES"
613
fi
714

8-
if [ -z "$LIBRARIES_PATH" ]; then
9-
LIBRARIES_PATH="${GITHUB_WORKSPACE}/libraries/"
10-
if [ ! -d "$LIBRARIES_PATH" ]; then
11-
LIBRARIES_PATH=$GITHUB_WORKSPACE
12-
fi
15+
getLibraryOptions() {
16+
local IFS=":"
17+
for library in $1
18+
do
19+
echo -n " -libraries $library"
20+
done
21+
}
22+
23+
BUILDER_OPTIONS="-hardware $BUILDER_PATH/hardware -tools $BUILDER_PATH/hardware/tools/avr -tools $BUILDER_PATH/tools-builder `getLibraryOptions $LIBRARIES_PATH` -fqbn $BOARD_NAME"
24+
25+
if [ -d "$INPUT_HARDWARE" ]; then
26+
BUILDER_OPTIONS="$BUILDER_OPTIONS -hardware $INPUT_HARDWARE"
1327
fi
1428

15-
if [ ! -z "$SKETCH_PATH" ]; then
16-
SKETCH_PATH=$(readlink -f "$SKETCH_PATH")
17-
cd /opt/arduino
29+
if [ -n "$SKETCH_PATH" ]; then
1830
if [ -z "$1" ]; then
19-
./arduino-builder -hardware ./hardware -tools ./hardware/tools/avr -tools ./tools-builder -libraries ./libraries -libraries $LIBRARIES_PATH -libraries $GITHUB_WORKSPACE/../ -fqbn $BOARD_NAME "$SKETCH_PATH"
31+
arduino-builder $BUILDER_OPTIONS "$SKETCH_PATH"
2032
else
21-
./arduino-builder "$@" "$SKETCH_PATH"
33+
arduino-builder "$@" "$SKETCH_PATH"
2234
fi
2335
else
24-
if [ -z "$SKETCH_DIRECTORY_PATH" ]; then
25-
SKETCH_DIRECTORY_PATH="${GITHUB_WORKSPACE}/examples/"
26-
fi
27-
28-
cd /opt/arduino
29-
for sketch in `find "${SKETCH_DIRECTORY_PATH}" -name '*.ino'`
36+
for sketch in `find "$SKETCH_DIRECTORY_PATH" -name '*.ino'`
3037
do
3138
if [ -z "$1" ]; then
32-
./arduino-builder -hardware ./hardware -tools ./hardware/tools/avr -tools ./tools-builder -libraries ./libraries -libraries $LIBRARIES_PATH -libraries $GITHUB_WORKSPACE/../ -fqbn $BOARD_NAME $sketch
39+
arduino-builder $BUILDER_OPTIONS "$sketch"
3340
else
34-
./arduino-builder "$@" $sketch
41+
arduino-builder "$@" "$sketch"
3542
fi
3643
done
3744
fi

0 commit comments

Comments
 (0)