diff --git a/.github/workflows/build_firmware.yml b/.github/workflows/build_firmware.yml index c160f98..81707fd 100644 --- a/.github/workflows/build_firmware.yml +++ b/.github/workflows/build_firmware.yml @@ -45,21 +45,36 @@ jobs: ../Tools/install.sh Esp8266 ../Tools/install.sh Esp32 - - name: Download SPA files artifact - uses: actions/download-artifact@v4 - with: - name: spa-files - path: ./webapp - repository: pljakobs/esp_rgb_webapp2 - github-token: ${{ secrets.artifact_download_token }} + - 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 - uses: actions/download-artifact@v4 - with: - name: fileList.h - path: ./include - repository: pljakobs/esp_rgb_webapp2 - github-token: ${{ secrets.artifact_download_token }} + 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 build: needs: setup