Skip to content
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
50 changes: 32 additions & 18 deletions .github/workflows/daily-contest-script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,43 @@ jobs:
- name: Install dependencies
run: pip install -r scripts/requirements.txt

- name: Create new branch
- name: Check if branch exists
run: |
git checkout -b automate-json-update
git push -u origin automate-json-update
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
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Action
author_email: action@github.com
message: Update JSON file
push: true
if: steps.git-diff.outputs.changes != ''
run: |
git config --local user.email "action@github.com"
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
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: Automated pull request for JSON file update
title: Automated Pull Request
branch: automate-json-update
base: main
body: |
This pull request updates the JSON file automatically.
if: steps.git-diff.outputs.changes != ''
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
hub pull-request -m "$pr_title" -b main -h "$pr_branch" -m "$pr_body"
58 changes: 0 additions & 58 deletions .github/workflows/main.yml

This file was deleted.