3rd Party JSON Files #4168
This file contains hidden or 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: 3rd Party JSON Files | |
| on: | |
| workflow_dispatch: | |
| push: | |
| schedule: | |
| - cron: "*/15 * * * *" # every 15 minutes | |
| jobs: | |
| compare-json: | |
| runs-on: ubuntu-latest | |
| env: | |
| FILES_ADDED: "false" | |
| FORCE_DOWNLOAD_ALL: ${{ github.event.inputs.force_download_all || 'false' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| #- name: Update Brench | |
| # run: | | |
| # git fetch | |
| # git pull origin main | |
| - name: Run Python script | |
| id: process | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GHOST_UPLOAD_TOKEN }} | |
| run: | | |
| # if force download is requested, delete all cached JSON files to ensure they are re-downloaded | |
| if [ "${{ env.FORCE_DOWNLOAD_ALL }}" = "true" ]; then | |
| find ./3rd/r -mindepth 1 -maxdepth 1 -type f -delete | |
| fi | |
| # Checks for firmware updates and writes new JSON files | |
| python ./3rd/bruce_beta.py | |
| python ./3rd/GhostESP.py | |
| python ./3rd/update_firmware.py | |
| # this script writes CHANGED and creates the all_device_firmware.json file based on the individual JSON files created by the previous scripts | |
| python ./3rd/create_json.py | |
| # the next script writes FILES_ADDED checking m5burner updates | |
| python ./v2/update_json.py ${{ env.FORCE_DOWNLOAD_ALL == 'true' && '--force-download-all' || '' }} | |
| - name: Check for .bin files | |
| id: check_bin | |
| run: | | |
| count=$(ls *.bin 2>/dev/null | wc -l) | |
| echo "Found $count .bin files" | |
| if [ "$count" -gt 0 ]; then | |
| echo "has_bin=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_bin=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Get release by tag | |
| if: steps.check_bin.outputs.has_bin == 'true' | |
| id: get_release | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const release = await github.rest.repos.getReleaseByTag({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| tag: "GhostESP" | |
| }); | |
| return release.data.id; | |
| - name: Delete old assets | |
| if: steps.check_bin.outputs.has_bin == 'true' | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const release_id = ${{ steps.get_release.outputs.result }}; | |
| const assets = await github.rest.repos.listReleaseAssets({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| release_id: release_id | |
| }); | |
| for (const asset of assets.data) { | |
| await github.rest.repos.deleteReleaseAsset({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| asset_id: asset.id | |
| }); | |
| } | |
| - name: Upload new asset | |
| if: steps.check_bin.outputs.has_bin == 'true' | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: GhostESP | |
| files: "*.bin" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Remove .bin files from repository | |
| if: steps.check_bin.outputs.has_bin == 'true' | |
| run: rm *.bin | |
| - name: Set up Git and commit changes | |
| if: steps.process.outputs.changed == 'true' || env.FILES_ADDED == 'true' | |
| run: | | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add . | |
| git commit -m "Update 3rd party JSON files" | |
| git push |