From ce7ba0c89abbbd2090b2e1904258e8abefdbf705 Mon Sep 17 00:00:00 2001 From: insolor <2442833+insolor@users.noreply.github.com> Date: Thu, 9 Jan 2025 10:11:28 +0300 Subject: [PATCH] Use a separate json file to pass update info for issue generation --- .github/workflows/check-for-updates.yml | 8 ++++---- .gitignore | 2 ++ main.py | 12 +++++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check-for-updates.yml b/.github/workflows/check-for-updates.yml index 8fffa48..f5f4c94 100644 --- a/.github/workflows/check-for-updates.yml +++ b/.github/workflows/check-for-updates.yml @@ -63,8 +63,8 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: latest_update - path: ./latest_update.json + name: full_update_info + path: ./full_update_info.json create-issue: needs: check-for-updates @@ -75,11 +75,11 @@ jobs: - name: Download artifact uses: actions/download-artifact@v4 with: - name: latest_update + name: full_update_info - name: Get data from json id: get_data - run: echo "json_data=$(cat latest_update.json)" >> $GITHUB_OUTPUT + run: echo "json_data=$(cat full_update_info.json)" >> $GITHUB_OUTPUT - name: Print data run: | diff --git a/.gitignore b/.gitignore index 505a3b1..daf6e36 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ wheels/ # Virtual environments .venv + +full_update_info.json diff --git a/main.py b/main.py index 24c49ca..11a7aaa 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,8 @@ df_app_id = 975370 root_dir = Path(__file__).parent -output_file = root_dir / "latest_update.json" +latest_update_file = root_dir / "latest_update.json" +full_update_info_file = root_dir / "full_update_info.json" def get_last_posts(*, count) -> list[dict[str, Any]]: @@ -32,17 +33,18 @@ def main(): posts = get_last_posts(count=1) post = posts[0] - if output_file.exists(): - prev_update = json.loads(output_file.read_text(encoding="utf-8")) + if latest_update_file.exists(): + prev_update = json.loads(latest_update_file.read_text(encoding="utf-8")) - if is_update(post["title"]) and (not output_file.exists() or prev_update["date"] < post["date"]): + if is_update(post["title"]) and (not latest_update_file.exists() or prev_update["date"] < post["date"]): prev_update = dict( gid=post["gid"], date=post["date"], title=post["title"], appid=post["appid"], ) - output_file.write_text(json.dumps(prev_update), encoding="utf-8") + latest_update_file.write_text(json.dumps(prev_update), encoding="utf-8") + full_update_info_file.write_text(json.dumps(post), encoding="utf-8") print("yes") else: print("no")