Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions .github/workflows/build_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,49 @@ jobs:
& "$Env:RUNNER_TOOL_CACHE\arduino-cli\arduino-cli.exe" --config-file "$Env:RUNNER_TOOL_CACHE\arduino-cli\config.yaml" lib install "TX07K-TXC@1.0.4"
& "$Env:RUNNER_TOOL_CACHE\arduino-cli\arduino-cli.exe" --config-file "$Env:RUNNER_TOOL_CACHE\arduino-cli\config.yaml" lib install "MQTTESP8266@5.1.2"

- name: Set configs (Windows)
- name: Generate configs from secrets repo
shell: powershell
run: |
$env:CONFIG_H | Out-File -Encoding ascii config.h
$env:SENSORSCONFIG_H | Out-File -Encoding ascii sensorsconfig.h
env:
CONFIG_H: ${{ secrets.CONFIG_H }}
SENSORSCONFIG_H: ${{ secrets.SENSORSCONFIG_H }}
SECRETS_SHARE_PATH: ${{ secrets.SECRETS_SHARE_PATH }}
SECRETS_SHARE_USER: ${{ secrets.SECRETS_SHARE_USER }}
SECRETS_SHARE_PASS: ${{ secrets.SECRETS_SHARE_PASS }}
SECRETS_REPO_NAME: ${{ secrets.SECRETS_REPO_NAME }}
DEVICE_NAME: HeaterTemperatureRegulator
run: |
$ErrorActionPreference = 'Stop'
$secretsDir = Join-Path $env:RUNNER_TEMP 'secrets'
$mounted = $false

try {
# Mount SMB share with read-only credentials
& net.exe use 'Z:' $env:SECRETS_SHARE_PATH /user:$env:SECRETS_SHARE_USER $env:SECRETS_SHARE_PASS | Out-Null
if ($LASTEXITCODE -ne 0) { throw "Failed to mount SMB share (exit $LASTEXITCODE)" }
$mounted = $true

# Clone Configuration repo from the share
if (Test-Path $secretsDir) { Remove-Item $secretsDir -Recurse -Force }
$repoSource = if ($env:SECRETS_REPO_NAME) { "Z:\$env:SECRETS_REPO_NAME" } else { 'Z:\' }
git clone --depth=1 $repoSource $secretsDir
if ($LASTEXITCODE -ne 0) { throw "git clone failed (exit $LASTEXITCODE)" }

# Run per-device deploy script
$deployScript = Join-Path $secretsDir "$env:DEVICE_NAME\deploy.ps1"
if (-not (Test-Path $deployScript)) { throw "deploy.ps1 not found at $deployScript" }

& $deployScript -OutputDir $env:GITHUB_WORKSPACE
if ($LASTEXITCODE -ne 0) { throw "deploy.ps1 failed (exit $LASTEXITCODE)" }
}
finally {
# Always clean up - whether the try block succeeded, threw, or was interrupted
if (Test-Path $secretsDir) {
Remove-Item $secretsDir -Recurse -Force -ErrorAction SilentlyContinue
}
if ($mounted) {
& net.exe use 'Z:' /delete /yes | Out-Null
}
# cleanup is best-effort; do not fail the step on a stale exit code
$global:LASTEXITCODE = 0
}

- name: Compile Arduino project
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pull_request_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
run: |
cp config_default.h config.h
cp sensorsconfig_default.h sensorsconfig.h
cp secret_default.h secret.h

- name: Static analysis
run: |
Expand Down
1 change: 1 addition & 0 deletions HeatingTemperatureRegulator.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "display.h"
#include <TX07K-TXC.h>
#include "config.h"
#include "secret.h"
#include <avr/wdt.h>
#include "TemperatureSensors.h"
#include "BelWattmeter.h"
Expand Down
8 changes: 0 additions & 8 deletions config_default.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
#define WifiSSID "WifiSSID"
#define WifiPassword "WifiPassword"
#define MQTTUsername "MQTTUserName"

#define MQTTPassword "MQTTPassword"

#define MQTTHost "MQTTHost"

#define TOPIC_THERMOSTAT "TOPIC_THERMOSTAT"
#define TOPIC_MODE "TOPIC_MODE"
#define TOPIC_HEATERSELECTOR "TOPIC_HEATERSELECTOR"
Expand Down
5 changes: 5 additions & 0 deletions secret_default.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#define WifiSSID "WifiSSID"
#define WifiPassword "WifiPassword"
#define MQTTUsername "MQTTUserName"
#define MQTTPassword "MQTTPassword"
#define MQTTHost "MQTTHost"
Loading