Your Christmas tree Pixel LED chain is:
- yellow, when a GitHub Actions workflow is in progress
- green, if success
- red, if failure
Basically it's ESP32 powered controller for WS2812 based pixel LED strip (chain) with HTTP API that is used by your GitHub Actions workflow.
ESP32 and GitHub Actions workflow are connected using https://github.com/husarnet/husarnet - a lightweight, p2p VPN that works directly on ESP32.
Prerequisites: Install Visual Studio Code with PlatformIO extension.Quick startChristmas Tree Setup
1. Hardware setup: my Pixel LED chain is connected to ESP32 pin no PIN 12
2. Clone the repo and open it in Visual Studio Code. Platformio should automatically install all project dependencies.
git clone https://github.com/DominikN/christmas-tree-lights
3. Rename credentials-template.h
to credentials.h
and type your WiFi an Husarnet credentials there (you will find you Husarnet Join Code at https://app.husarnet.com).
4. Click "PlatformIO: upload" button to flash your ESP32 board connected to your laptop. You will find the following log in the serial monitor:
**************************************
Christmas Tree Lights
**************************************
📻 1. Connecting to: FreeWifi Wi-Fi network .. done
⌛ 2. Waiting for Husarnet to be ready ... done
🚀 HTTP server started
Visit:
http://pixel-led-chain:8080/
Known hosts:
my-laptop (fc94:a4c1:1f22:ab3b:b04a:1a3b:ba15:84bc)
pixel-led-chain (fc94:f632:c8d9:d2a6:ad18:ed16:ed7e:9f3f)
5. At this point other devices from the same Husarnet network can access your Pixel LED strip over the Internet and use it's HTTP API. Here are some examples.
curl http://pixel-led-chain:8080/mode=0
- setmodeRGB=0
(rainbow theme)curl http://pixel-led-chain:8080/color=red
- setmodeRGB=5
andrgb={255,0,0}
(all LEDs red)curl http://pixel-led-chain:8080/color=yellow
- setmodeRGB=5
andrgb={255,255,0}
(all LEDs yellow):curl http://pixel-led-chain:8080/color=green
- setmodeRGB=5
andrgb={0,255,0}
(all LEDs green)
1. In the target repository (for which GitHub workflow status you want to be displayed on a Christmas Tree) create a new GitHub repository secret:
HUSARNET_JOINCODE
And paste as a value the same Join Code as in the Christmas Tree setup section above.
2. Modify your existing GitHub Actions workflow YAML by adding these lines just bellow steps:
key:
- name: Connecting VPN
uses: husarnet/husarnet-action@v2
with:
join-code: ${{ secrets.HUSARNET_JOINCODE }}
- name: Set Christmas tree yellow
run: curl http://pixel-led-chain:8080/color=yellow
And these lines on very end:
- name: Step to run on failure
if: ${{ failure() }}
run: curl http://pixel-led-chain:8080/color=red
- name: Step to run on success
if: ${{ success() }}
run: curl http://pixel-led-chain:8080/color=green
- name: Quit VPN
if: ${{ always() }}
run: sudo systemctl stop husarnet
FULL EXAMPLEExample .github/workflows/fake-workflow.yml
file content:
name: Fake workflow
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Connecting VPN
uses: husarnet/husarnet-action@v2
with:
join-code: ${{ secrets.HUSARNET_JOINCODE }}
- name: Set Christmas tree yellow
run: curl http://pixel-led-chain:8080/color=yellow
- name: run something that fails
run: |
echo "building something..."
sleep 5
echo "testing somethings..."
sleep 5
echo "fail!"
exit 1
- name: Step to run on failure
if: ${{ failure() }}
run: curl http://pixel-led-chain:8080/color=red
- name: Step to run on success
if: ${{ success() }}
run: curl http://pixel-led-chain:8080/color=green
- name: Quit VPN
if: ${{ always() }}
run: sudo systemctl stop husarnet
And that's all! I hope you will like it.
Cheers!
Comments
Please log in or sign up to comment.