CI: fix GDOOR_VERSION variable #31
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
name: PlatformIO CI | |
on: | |
push: | |
paths: # only run if firmware changes | |
- 'firmware/**' | |
- '.github/workflows/firmware.yml' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./firmware/esp32/gdoor | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/pip | |
~/.platformio/.cache | |
key: ${{ runner.os }}-pio | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Set GDOOR_VERSION environment variable | |
run: | | |
if [[ "$GITHUB_REF" == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
else | |
VERSION=${GITHUB_REF#refs/heads/} | |
fi | |
SHORT_SHA=$(git rev-parse --short HEAD) | |
echo "GDOOR_VERSION=${VERSION}+${SHORT_SHA}" >> $GITHUB_ENV | |
- name: Install PlatformIO Core | |
run: pip install --upgrade platformio | |
- name: Build PlatformIO Project | |
run: pio run | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gdoor_firmware | |
path: | | |
./firmware/esp32/gdoor/.pio/build/GDOOR_ESP32MINI/*.bin | |
./firmware/esp32/gdoor/.pio/build/GDOOR_ESP32MINI/web | |
# on main branch: push firmware to web flasher | |
- name: Push firmware to website repo for web flasher | |
if: github.ref == 'refs/heads/main' | |
uses: cpina/github-action-push-to-another-repository@main | |
env: | |
SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} | |
with: | |
source-directory: './firmware/esp32/gdoor/.pio/build/GDOOR_ESP32MINI/web' | |
target-directory: 'assets/firmware' | |
destination-github-username: 'gdoor-org' | |
destination-repository-name: 'gdoor-org.github.io' | |
target-branch: main | |
user-name: 'github-actions[bot]' | |
commit-message: 'Latest firmware for web flasher via ORIGIN_COMMIT' |