Skip to content

trying to fix the deploy workflow (this process is annoying) #89

trying to fix the deploy workflow (this process is annoying)

trying to fix the deploy workflow (this process is annoying) #89

name: Application CI
on:
push:
branches: [develop]
pull_request:
branches: [develop]
repository_dispatch:
types: [frontend-build-completed]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
soc: [esp8266, esp32, esp32c3]
release: [0, 1]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: develop
- name: Synchronize submodules
run: git submodule update --init --recursive
- name: Pull Docker Image
run: docker pull docker.io/pjakobs/sming:latest
- name: Get Latest Successful Workflow Run
id: get_run
run: |
latest_run_id=$(curl -s -H "Authorization: token ${{ secrets.artifact_download_token }}" \
"https://api.github.com/repos/pljakobs/esp_rgb_webapp2/actions/runs?status=success&branch=devel" | \
jq -r '.workflow_runs[0].id')
echo "latest_run_id=$latest_run_id" >> $GITHUB_ENV
- name: Download fileList.h artifact
run: |
if [ -f ./include/fileList.h ]; then
rm ./include/fileList.h
fi
artifact_url=$(curl -s -H "Authorization: token ${{ secrets.artifact_download_token }}" \
"https://api.github.com/repos/pljakobs/esp_rgb_webapp2/actions/runs/${{ env.latest_run_id }}/artifacts" | \
jq -r '.artifacts[] | select(.name=="fileList.h") | .archive_download_url')
curl -L -o fileList.h.zip -H "Authorization: token ${{ secrets.artifact_download_token }}" "$artifact_url"
unzip fileList.h.zip -d ./include
- name: Download webapp files artifact
run: |
if [ -d ./webapp ]; then
rm -rf ./webapp
mkdir ./webapp
fi
artifact_url=$(curl -s -H "Authorization: token ${{ secrets.artifact_download_token }}" \
"https://api.github.com/repos/pljakobs/esp_rgb_webapp2/actions/runs/${{ env.latest_run_id }}/artifacts" | \
jq -r '.artifacts[] | select(.name=="spa-files") | .archive_download_url')
curl -L -o spa-files.zip -H "Authorization: token ${{ secrets.artifact_download_token }}" "$artifact_url"
unzip spa-files.zip -d ./webapp
- name: Build partition map (ESP8266 only)
if: ${{ matrix.soc == 'esp8266' }}
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
docker.io/pjakobs/sming:latest \
bash -c "git config --global --add safe.directory /workspace && \
source /opt/Sming/Tools/export.sh && \
make partmap-build" SMING_SOC=${{ matrix.soc }} SMING_RELEASE=${{ matrix.release }}
- name: Copy partition map for release build (ESP8266 only)
if: ${{ matrix.soc == 'esp8266' && matrix.release == 1 }}
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
docker.io/pjakobs/sming:latest \
bash -c "mkdir -p /workspace/out/Esp8266/release/firmware && cp /workspace/out/Esp8266/debug/firmware/partitions.bin /workspace/out/Esp8266/release/firmware/"
- name: Run Build in Docker Container
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace \
docker.io/pjakobs/sming:latest \
bash -c "git config --global --add safe.directory /workspace && \
source /opt/Sming/Tools/export.sh && \
make SMING_SOC=${{ matrix.soc }} SMING_RELEASE=${{ matrix.release }} DISABLE_WERROR=1"
# Determine correct artifact path based on matrix.soc and matrix.release
- name: Set firmware path
id: set_firmware_path
run: |
if [ "${{ matrix.soc }}" = "esp8266" ] && [ "${{ matrix.release }}" = "0" ]; then
echo "path=out/Esp8266/debug/build/app_0.out" >> $GITHUB_OUTPUT
elif [ "${{ matrix.soc }}" = "esp8266" ] && [ "${{ matrix.release }}" = "1" ]; then
echo "path=out/Esp8266/release/build/app_0.out" >> $GITHUB_OUTPUT
elif [ "${{ matrix.soc }}" = "esp32" ] && [ "${{ matrix.release }}" = "0" ]; then
echo "path=out/Esp32/esp32/debug/firmware/app.bin" >> $GITHUB_OUTPUT
elif [ "${{ matrix.soc }}" = "esp32" ] && [ "${{ matrix.release }}" = "1" ]; then
echo "path=out/Esp32/esp32/release/firmware/app.bin" >> $GITHUB_OUTPUT
elif [ "${{ matrix.soc }}" = "esp32c3" ] && [ "${{ matrix.release }}" = "0" ]; then
echo "path=out/Esp32/esp32c3/debug/firmware/app.bin" >> $GITHUB_OUTPUT
elif [ "${{ matrix.soc }}" = "esp32c3" ] && [ "${{ matrix.release }}" = "1" ]; then
echo "path=out/Esp32/esp32c3/release/firmware/app.bin" >> $GITHUB_OUTPUT
else
echo "path=" >> $GITHUB_OUTPUT
fi
- name: Set artifact name
id: set_artifact_name
run: |
if [ "${{ matrix.release }}" = "1" ]; then
echo "artifact_name=lightinator-${{ matrix.soc }}-release" >> $GITHUB_OUTPUT
else
echo "artifact_name=lightinator-${{ matrix.soc }}-debug" >> $GITHUB_OUTPUT
fi
- name: Upload firmware artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.set_artifact_name.outputs.artifact_name }}
path: ${{ steps.set_firmware_path.outputs.path }}