Skip to content

Try again

Try again #54

name: Update leaderboard on PR Merge.
on:
pull_request:
types: [opened, reopened, synchronize]
# pull_request:
# branches:
# - development
# types:
# [closed]
jobs:
leaderboard_evaluation:
runs-on: ubuntu-latest
steps:
# Check changes in the source branch of the PR
- name: Check if there are any changes in submissions dir
uses: dorny/[email protected]
id: changes
with:
filters: |
src:
- 'session_2/challenge/submissions/**'
list-files: "shell"
- name: Print changed files
run: |
echo '${{ toJSON(steps.changes.outputs) }}'
- if: ${{ (steps.changes.outputs.src_count > 1) }}
uses: actions/github-script@v7
with:
script: core.setFailed('More than one submissions are not allowed at once.')
# Update leaderboard only if single file is changed in submission dir
- if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
name: Checkout code
uses: actions/checkout@v4
with:
# Here we checkout the target branch of the PR
repository: ${{ github.event.pull_request.base.repo.full_name }}
ref: ${{ github.event.pull_request.base.ref }}
- if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r session_2/challenge/requirements.txt
- if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
name: Run leaderboard update script
id: leaderboard-update
run: |
cd session_2/challenge
filename=$(basename "${{ steps.changes.outputs.src_files }}")
filename_without_extension="${filename%.*}" # Remove extension
python -m scripts.leaderboard --github_user="${{ github.event.pull_request.user.login }}" --prompt="$filename_without_extension"
# - if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
# name: Commit changes
# uses: EndBug/add-and-commit@v9
# with:
# default_author: github_actions
- if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
name: Commit and push changes
run: |
git config --global user.name "hetulvp"
git config --global user.email "[email protected]"
git add .
git commit -m "Updated leaderboard"
git push
env:
PAT_TOKEN: ${{ secrets.GH_PAT }}