Skip to content

Commit

Permalink
Merge pull request #413 from ssavi-ict/company_info
Browse files Browse the repository at this point in the history
scripts updated
  • Loading branch information
ssavi-ict authored Apr 11, 2024
2 parents 5969d91 + 669a110 commit 0c757db
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/daily-contest-script_win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Daily Contest Script

on:
schedule:
- cron: '0 0 * * *' # Schedule the workflow to run at 00:00 UTC daily
workflow_dispatch:

jobs:
run_contest_script:
runs-on: windows-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: pip install -r scripts/requirements.txt

- name: Check if branch exists
run: |
branch_exists=$(git ls-remote --exit-code --heads origin automate-c-json-update || echo "")
if [ -n "$branch_exists" ]; then
git fetch origin automate-c-json-update
git checkout automate-c-json-update
else
git checkout -b automate-c-json-update
fi
- name: Run contest.py script
run: python scripts/contest.py

- name: Check for changes
id: git-diff
run: |
git fetch origin main
changes=$(git diff --name-only main -- data/contests.json)
echo "::set-output name=changes::$changes"
- name: Commit and push changes
if: steps.git-diff.outputs.changes != ''
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add data/contests.json
git commit -m "Update JSON file"
git push origin automate-c-json-update
- name: Create Pull Request
if: steps.git-diff.outputs.changes != ''
run: |
pr_branch="automate-c-json-update"
pr_title="Automated Pull Request"
pr_body="This pull request updates the JSON file automatically."
# Create the pull request using the GitHub API
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d "{\"title\":\"$pr_title\",\"body\":\"$pr_body\",\"head\":\"$pr_branch\",\"base\":\"main\"}" \
"https://api.github.com/repos/$GITHUB_REPOSITORY/pulls"
2 changes: 1 addition & 1 deletion data/contests.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"weekly-contest-390": {"title": "Weekly Contest 390", "start_time": 1711247400, "contest_duration": 5400}, "biweekly-contest-127": {"title": "Biweekly Contest 127", "start_time": 1711809000, "contest_duration": 5400}}
{"weekly-contest-393": {"title": "Weekly Contest 393", "start_time": 1713061800, "contest_duration": 5400}, "biweekly-contest-128": {"title": "Biweekly Contest 128", "start_time": 1713018600, "contest_duration": 5400}}
2 changes: 1 addition & 1 deletion scripts/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class CONTEST(object):
def __init__(self, contest_info_path):
self.contest_info_path = contest_info_path
self.header = headers = {
self.header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}

Expand Down

0 comments on commit 0c757db

Please sign in to comment.