-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
209 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md | ||
name: Sync Labels | ||
|
||
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows | ||
on: | ||
push: | ||
paths: | ||
- ".github/workflows/sync-labels.ya?ml" | ||
- ".github/label-configuration-files/*.ya?ml" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/sync-labels.ya?ml" | ||
- ".github/label-configuration-files/*.ya?ml" | ||
schedule: | ||
# Run daily at 8 AM UTC to sync with changes to shared label configurations. | ||
- cron: "0 8 * * *" | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
env: | ||
CONFIGURATIONS_FOLDER: .github/label-configuration-files | ||
CONFIGURATIONS_ARTIFACT: label-configuration-files | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download JSON schema for labels configuration file | ||
id: download-schema | ||
uses: carlosperate/[email protected] | ||
with: | ||
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json | ||
location: ${{ runner.temp }}/label-configuration-schema | ||
|
||
- name: Install JSON schema validator | ||
run: | | ||
sudo npm install \ | ||
--global \ | ||
ajv-cli \ | ||
ajv-formats | ||
- name: Validate local labels configuration | ||
run: | | ||
# See: https://github.com/ajv-validator/ajv-cli#readme | ||
ajv validate \ | ||
--all-errors \ | ||
-c ajv-formats \ | ||
-s "${{ steps.download-schema.outputs.file-path }}" \ | ||
-d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" | ||
download: | ||
needs: check | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
filename: | ||
# Filenames of the shared configurations to apply to the repository in addition to the local configuration. | ||
# https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels | ||
- universal.yml | ||
|
||
steps: | ||
- name: Download | ||
uses: carlosperate/[email protected] | ||
with: | ||
file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} | ||
|
||
- name: Pass configuration files to next job via workflow artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: | | ||
*.yaml | ||
*.yml | ||
if-no-files-found: error | ||
name: ${{ env.CONFIGURATIONS_ARTIFACT }} | ||
|
||
sync: | ||
needs: download | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set environment variables | ||
run: | | ||
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable | ||
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" | ||
- name: Determine whether to dry run | ||
id: dry-run | ||
if: > | ||
github.event_name == 'pull_request' || | ||
( | ||
( | ||
github.event_name == 'push' || | ||
github.event_name == 'workflow_dispatch' | ||
) && | ||
github.ref != format('refs/heads/{0}', github.event.repository.default_branch) | ||
) | ||
run: | | ||
# Use of this flag in the github-label-sync command will cause it to only check the validity of the | ||
# configuration. | ||
echo "::set-output name=flag::--dry-run" | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download configuration files artifact | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: ${{ env.CONFIGURATIONS_ARTIFACT }} | ||
path: ${{ env.CONFIGURATIONS_FOLDER }} | ||
|
||
- name: Remove unneeded artifact | ||
uses: geekyeggo/delete-artifact@v1 | ||
with: | ||
name: ${{ env.CONFIGURATIONS_ARTIFACT }} | ||
|
||
- name: Merge label configuration files | ||
run: | | ||
# Merge all configuration files | ||
shopt -s extglob | ||
cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" | ||
- name: Install github-label-sync | ||
run: sudo npm install --global github-label-sync | ||
|
||
- name: Sync labels | ||
env: | ||
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# See: https://github.com/Financial-Times/github-label-sync | ||
github-label-sync \ | ||
--labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ | ||
${{ steps.dry-run.outputs.flag }} \ | ||
${{ github.repository }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Pager Server | ||
A simple server that echoes any incoming messages to all | ||
connected clients. Connect two or more telnet sessions | ||
to see how server.available() and server.print() works. | ||
created in September 2020 for the Ethernet library | ||
by Juraj Andrassy https://github.com/jandrassy | ||
*/ | ||
#include <Ethernet.h> | ||
|
||
// Enter a MAC address for your controller below. | ||
// Newer Ethernet shields have a MAC address printed on a sticker on the shield | ||
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; | ||
|
||
// Set the static IP address to use if the DHCP fails to assign | ||
IPAddress ip(192, 168, 0, 177); | ||
|
||
EthernetServer server(2323); | ||
|
||
void setup() { | ||
|
||
Serial.begin(9600); | ||
while (!Serial); | ||
|
||
// start the Ethernet connection: | ||
Serial.println("Initialize Ethernet with DHCP:"); | ||
if (Ethernet.begin(mac) == 0) { | ||
Serial.println("Failed to configure Ethernet using DHCP"); | ||
// Check for Ethernet hardware present | ||
if (Ethernet.hardwareStatus() == EthernetNoHardware) { | ||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); | ||
while (true) { | ||
delay(1); // do nothing, no point running without Ethernet hardware | ||
} | ||
} | ||
if (Ethernet.linkStatus() == LinkOFF) { | ||
Serial.println("Ethernet cable is not connected."); | ||
} | ||
// try to congifure using IP address instead of DHCP: | ||
Ethernet.begin(mac, ip); | ||
} else { | ||
Serial.print(" DHCP assigned IP "); | ||
Serial.println(Ethernet.localIP()); | ||
} | ||
|
||
server.begin(); | ||
|
||
IPAddress ip = Ethernet.localIP(); | ||
Serial.println(); | ||
Serial.print("To access the server, connect with Telnet client to "); | ||
Serial.print(ip); | ||
Serial.println(" 2323"); | ||
} | ||
|
||
void loop() { | ||
|
||
EthernetClient client = server.available(); // returns first client which has data to read or a 'false' client | ||
if (client) { // client is true only if it is connected and has data to read | ||
String s = client.readStringUntil('\n'); // read the message incoming from one of the clients | ||
s.trim(); // trim eventual \r | ||
Serial.println(s); // print the message to Serial Monitor | ||
client.print("echo: "); // this is only for the sending client | ||
server.println(s); // send the message to all connected clients | ||
server.flush(); // flush the buffers | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters