-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from ssavi-ict/company_info
scripts updated
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters