Skip to content

Commit

Permalink
use sysenv for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielmarcano committed Aug 9, 2023
1 parent c1c3c9d commit 5637a0b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Load environment variables
run: |
mv src/env-template.h src/env.h
# - name: Load environment variables
# run: |
# mv src/env-template.h src/env.h

- name: Installing platformio
run: pip3 install -U platformio

- name: Building a firmware
run: |
export SSID=${{ secrets.WIFI_SSID }}
export PASS=${{ secrets.WIFI_PASS }}
export JOINCODE=${{ secrets.HUSARNET_JOINCODE }}
export HOSTNAME=${{ secrets.HUSARNET_HOSTNAME }}
pio lib install
pio run
6 changes: 6 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ lib_deps =
adafruit/Adafruit Unified Sensor@^1.1.9
bblanchon/ArduinoJson@^6.21.2
ayushsharma82/AsyncElegantOTA@^2.2.7

build_flags =
-D WSSID="${sysenv.SSID}"
-D WPASS="${sysenv.PASS}"
-D HN_HOSTNAME="${sysenv.HOSTNAME}"
-D HN_JOINCODE="${sysenv.JOINCODE}"
25 changes: 22 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <Arduino.h>

// Get credentials
#include <env.h>

#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
Expand All @@ -17,6 +14,28 @@
#include "DHT.h"
#include "max6675.h"

#if __has_include("env.h")

// For local development (rename env-template.h and type your WiFi and
// Husarnet credentials there)
#include <env.h>

#else

// For GitHub Actions OTA deployment

// WiFi credentials
#define WIFI_SSID WSSID
#define WIFI_PASS WPASS

// Husarnet credentials
#define HUSARNET_JOIN_CODE HN_JOINCODE
#define HUSARNET_HOSTNAME HN_HOSTNAME

#endif

// #include <env.h>

#define LCD_SDA 21
#define LCD_SCL 22
#define MAX_SCK 5
Expand Down

0 comments on commit 5637a0b

Please sign in to comment.