From 3816439ef5f9d8a2d5a39abe94bf0306068aefe5 Mon Sep 17 00:00:00 2001 From: drojf <1249449+drojf@users.noreply.github.com> Date: Wed, 7 Feb 2024 21:20:50 +1100 Subject: [PATCH] Build json file --- .github/workflows/build.yml | 29 +++++++++++++++++++++++++++++ .gitignore | 1 + build.py | 21 +++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .gitignore create mode 100644 build.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..85ef363 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build updates.json file + +# Run this workflow on every push or pull request +on: + push: + +# Docs on sharing data between jobs (between VMs): https://help.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#passing-data-between-jobs-in-a-workflow +jobs: + json_build: + name: ubuntu build + runs-on: ubuntu-latest + + steps: + - name: Download Repository + uses: actions/checkout@v3 + + - name: Run Build and Deploy Script + run: python build.py + + - name: Release (tag) + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') # only publish tagged commits + with: + files: | + *.json + # draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a2003d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +updates.json \ No newline at end of file diff --git a/build.py b/build.py new file mode 100644 index 0000000..d57b6b1 --- /dev/null +++ b/build.py @@ -0,0 +1,21 @@ +import json +from pathlib import Path + +out_json_path = 'updates.json' + +combined = {} + + +for file in Path('.').glob('*.html'): + with open(file, encoding='utf-8') as f: + all_html = f.read() + + name = file.stem + + combined[name] = { + 'status': all_html + } + + +with open(out_json_path, 'w', encoding="utf-8") as file: + json.dump(combined, file)