├── .github ├── dependabot.yml └── workflows │ ├── sync-labels.yml │ └── test.yaml ├── LICENSE ├── README.md └── blink └── blink.ino /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file 2 | version: 2 3 | 4 | updates: 5 | # Configure check for outdated GitHub Actions actions in workflows. 6 | # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/dependabot/README.md 7 | # See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot 8 | - package-ecosystem: github-actions 9 | directory: / # Check the repository's workflows under /.github/workflows/ 10 | assignees: 11 | - per1234 12 | schedule: 13 | interval: daily 14 | labels: 15 | - "topic: infrastructure" 16 | 17 | - package-ecosystem: github-actions 18 | target-branch: compile-sketches-demo 19 | directory: / 20 | assignees: 21 | - per1234 22 | schedule: 23 | interval: daily 24 | labels: 25 | - "topic: infrastructure" 26 | -------------------------------------------------------------------------------- /.github/workflows/sync-labels.yml: -------------------------------------------------------------------------------- 1 | # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md 2 | name: Sync Labels 3 | 4 | # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows 5 | on: 6 | push: 7 | paths: 8 | - ".github/workflows/sync-labels.ya?ml" 9 | - ".github/label-configuration-files/*.ya?ml" 10 | pull_request: 11 | paths: 12 | - ".github/workflows/sync-labels.ya?ml" 13 | - ".github/label-configuration-files/*.ya?ml" 14 | schedule: 15 | # Run daily at 8 AM UTC to sync with changes to shared label configurations. 16 | - cron: "0 8 * * *" 17 | workflow_dispatch: 18 | repository_dispatch: 19 | 20 | env: 21 | CONFIGURATIONS_FOLDER: .github/label-configuration-files 22 | CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file- 23 | 24 | jobs: 25 | check: 26 | runs-on: ubuntu-latest 27 | 28 | steps: 29 | - name: Checkout repository 30 | uses: actions/checkout@v4 31 | 32 | - name: Download JSON schema for labels configuration file 33 | id: download-schema 34 | uses: carlosperate/download-file-action@v2 35 | with: 36 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json 37 | location: ${{ runner.temp }}/label-configuration-schema 38 | 39 | - name: Install JSON schema validator 40 | run: | 41 | sudo npm install \ 42 | --global \ 43 | ajv-cli \ 44 | ajv-formats 45 | 46 | - name: Validate local labels configuration 47 | run: | 48 | # See: https://github.com/ajv-validator/ajv-cli#readme 49 | ajv validate \ 50 | --all-errors \ 51 | -c ajv-formats \ 52 | -s "${{ steps.download-schema.outputs.file-path }}" \ 53 | -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" 54 | 55 | download: 56 | needs: check 57 | runs-on: ubuntu-latest 58 | 59 | strategy: 60 | matrix: 61 | filename: 62 | # Filenames of the shared configurations to apply to the repository in addition to the local configuration. 63 | # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels 64 | - universal.yml 65 | - tooling.yml 66 | 67 | steps: 68 | - name: Download 69 | uses: carlosperate/download-file-action@v2 70 | with: 71 | file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} 72 | 73 | - name: Pass configuration files to next job via workflow artifact 74 | uses: actions/upload-artifact@v4 75 | with: 76 | path: | 77 | *.yaml 78 | *.yml 79 | if-no-files-found: error 80 | name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}${{ matrix.filename }} 81 | 82 | sync: 83 | needs: download 84 | runs-on: ubuntu-latest 85 | 86 | steps: 87 | - name: Set environment variables 88 | run: | 89 | # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable 90 | echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" 91 | 92 | - name: Determine whether to dry run 93 | id: dry-run 94 | if: > 95 | github.event_name == 'pull_request' || 96 | ( 97 | ( 98 | github.event_name == 'push' || 99 | github.event_name == 'workflow_dispatch' 100 | ) && 101 | github.ref != format('refs/heads/{0}', github.event.repository.default_branch) 102 | ) 103 | run: | 104 | # Use of this flag in the github-label-sync command will cause it to only check the validity of the 105 | # configuration. 106 | echo "::set-output name=flag::--dry-run" 107 | 108 | - name: Checkout repository 109 | uses: actions/checkout@v4 110 | 111 | - name: Download configuration file artifacts 112 | uses: actions/download-artifact@v4 113 | with: 114 | merge-multiple: true 115 | pattern: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}* 116 | path: ${{ env.CONFIGURATIONS_FOLDER }} 117 | 118 | - name: Remove unneeded artifacts 119 | uses: geekyeggo/delete-artifact@v5 120 | with: 121 | name: ${{ env.CONFIGURATIONS_ARTIFACT_PREFIX }}* 122 | 123 | - name: Merge label configuration files 124 | run: | 125 | # Merge all configuration files 126 | shopt -s extglob 127 | cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" 128 | 129 | - name: Install github-label-sync 130 | run: sudo npm install --global github-label-sync 131 | 132 | - name: Sync labels 133 | env: 134 | GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} 135 | run: | 136 | # See: https://github.com/Financial-Times/github-label-sync 137 | github-label-sync \ 138 | --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ 139 | ${{ steps.dry-run.outputs.flag }} \ 140 | ${{ github.repository }} 141 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | # This is the name of the workflow, visible on GitHub UI. 2 | name: test 3 | 4 | # Here we tell GitHub to run the workflow when a commit 5 | # is pushed or a Pull Request is opened. 6 | on: [push, pull_request] 7 | 8 | # This is the list of jobs that will be run concurrently. 9 | # Since we use a build matrix, the actual number of jobs 10 | # started depends on how many configurations the matrix 11 | # will produce. 12 | jobs: 13 | # This is the name of the job - can be whatever. 14 | test-matrix: 15 | 16 | # Here we tell GitHub that the jobs must be determined 17 | # dynamically depending on a matrix configuration. 18 | strategy: 19 | matrix: 20 | # The matrix will produce one job for each configuration 21 | # parameter of type `arduino-platform`, in this case a 22 | # total of 2. 23 | arduino-platform: ["arduino:samd", "arduino:avr"] 24 | # This is usually optional but we need to statically define the 25 | # FQBN of the boards we want to test for each platform. In the 26 | # future the CLI might automatically detect and download the core 27 | # needed to compile against a certain FQBN, at that point the 28 | # following `include` section will be useless. 29 | include: 30 | # This works like this: when the platform is "arduino:samd", the 31 | # variable `fqbn` is set to "arduino:samd:nano_33_iot". 32 | - arduino-platform: "arduino:samd" 33 | fqbn: "arduino:samd:nano_33_iot" 34 | - arduino-platform: "arduino:avr" 35 | fqbn: "arduino:avr:unowifi" 36 | 37 | # This is the platform GitHub will use to run our workflow, we 38 | # pick Windows for no particular reason. 39 | runs-on: windows-latest 40 | 41 | # This is the list of steps this job will run. 42 | steps: 43 | # First of all, we clone the repo using the `checkout` action. 44 | - name: Checkout 45 | uses: actions/checkout@v4 46 | 47 | # We use the `arduino/setup-arduino-cli` action to install and 48 | # configure the Arduino CLI on the system. 49 | - name: Setup Arduino CLI 50 | uses: arduino/setup-arduino-cli@v2 51 | 52 | # We then install the platform, which one will be determined 53 | # dynamically by the build matrix. 54 | - name: Install platform 55 | run: | 56 | arduino-cli core update-index 57 | arduino-cli core install ${{ matrix.arduino-platform }} 58 | 59 | # Finally, we compile the sketch, using the FQBN that was set 60 | # in the build matrix. 61 | - name: Compile Sketch 62 | run: arduino-cli compile --fqbn ${{ matrix.fqbn }} ./blink 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Arduino on GitHub Actions 2 | 3 | [![Actions Status](https://github.com/arduino/arduino-cli-example/workflows/test/badge.svg)](https://github.com/arduino/arduino-cli-example/actions) 4 | 5 | This repo is the companion of a blog post on Arduino's engineering blog about 6 | using Arduino tools in GitHub workflows and it has no other purpose than 7 | showing example code. 8 | 9 | The post can be found here: [Arduino on GitHub Actions](https://blog.arduino.cc/2019/11/14/arduino-on-github-actions/). 10 | -------------------------------------------------------------------------------- /blink/blink.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | 4 | Turns an LED on for one second, then off for one second, repeatedly. 5 | 6 | Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 7 | it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to 8 | the correct LED pin independent of which board is used. 9 | If you want to know what pin the on-board LED is connected to on your Arduino 10 | model, check the Technical Specs of your board at: 11 | https://www.arduino.cc/en/Main/Products 12 | 13 | modified 8 May 2014 14 | by Scott Fitzgerald 15 | modified 2 Sep 2016 16 | by Arturo Guadalupi 17 | modified 8 Sep 2016 18 | by Colby Newman 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/Blink 23 | */ 24 | 25 | // the setup function runs once when you press reset or power the board 26 | void setup() { 27 | // initialize digital pin LED_BUILTIN as an output. 28 | pinMode(LED_BUILTIN, OUTPUT); 29 | } 30 | 31 | // the loop function runs over and over again forever 32 | void loop() { 33 | digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) 34 | delay(1000); // wait for a second 35 | digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW 36 | delay(1000); // wait for a second 37 | } 38 | --------------------------------------------------------------------------------