Skip to content

Commit

Permalink
Use a separate json file to pass update info for issue generation
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Jan 9, 2025
1 parent 18c54aa commit ce7ba0c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/check-for-updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ wheels/

# Virtual environments
.venv

full_update_info.json
12 changes: 7 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand All @@ -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")
Expand Down

0 comments on commit ce7ba0c

Please sign in to comment.