Skip to content

Correct absolute path for run-cron GitHub Action #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
python cron/update_questions.py
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: update questions (cron job)
commit_message: Update questions via run-cron GitHub Action
16 changes: 10 additions & 6 deletions cron/update_questions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import requests
from datetime import datetime
import json

query = '''query questionData($titleSlug: String!) {
question(titleSlug: $titleSlug) {
Expand All @@ -9,9 +10,9 @@
}
'''

questions_file = "../src/data/questions.json"
questions_file = os.getcwd() + "/src/data/questions.json"

print("Reading questions file")
print("=== Reading questions file ===")

try:
with open(questions_file, "r") as file:
Expand All @@ -20,7 +21,9 @@
print(e)
exit()

print("Updating question metadata")
print("=== Updating question metadata ===")

startTime = datetime.now()

for question in questions["data"]:
variables = {"titleSlug": question["url"]}
Expand All @@ -36,7 +39,7 @@
print(f'{question["name"]}: {our_difficulty} -> {leetcode_difficulty}')
question["difficulty"] = leetcode_difficulty

print("Finished checking all questions")
print("=== Finished checking all questions ===")

try:
with open(questions_file, "w") as file:
Expand All @@ -46,4 +49,5 @@
print(e)
exit()

print("Wrote questions file")
print("=== Wrote questions file ===")
print(f'=== Script took: {datetime.now() - startTime} seconds ===')