Skip to content

Fix username

Fix username #55

name: Update leader board after submission merge.
on:
push:
branches:
- development
jobs:
update-file:
if: github.repository == 'infocusp/llm_seminar_series'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get merge commit hash
id: merge_commit
run: |
echo $GITHUB_SHA
echo "$(git log --merges --pretty=format:%H -5)"
merge_commit=$(git log --merges --pretty=format:%H -1 $GITHUB_SHA)
echo $merge_commit
echo "::set-output name=merge_commit::$merge_commit"
- name: Get second-to-last author's name
id: second_last_author_name
run: |
echo "$(git log --format='%ae' -n 2 ${{ steps.merge_commit.outputs.merge_commit }})"
second_last_author_name=$(git log --format='%ae' -n 2 ${{ steps.merge_commit.outputs.merge_commit }} | tail -n 1)
echo $second_last_author_name
echo "::set-output name=second_last_author_name::$second_last_author_name"
- name: Print author's name
run: echo "${{ steps.second_last_author_name.outputs.second_last_author_name }}"
- name: Check if there are any changes in submissions dir
uses: dorny/[email protected]
id: changes
with:
# Use context to get the branch where commits were pushed.
# If there is only one long-lived branch (e.g. master),
# you can specify it directly.
# If it's not configured, the repository default branch is used.
base: ${{ github.ref }}
filters: |
src:
- added|modified: '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.')
# # TODO(hetul): Get github profile from email https://api.github.com/search/users?q=EMAIL
# - if: ${{ (steps.changes.outputs.src == 'true') && (steps.changes.outputs.src_count == 1) }}
# name: Get author's name from last commit
# id: author_name
# run: |
# # author_name=$(git log -1 --pretty=format:'%an' -- "${{ steps.changes.outputs.src_files }}")
# author_name=$("${{ github.event.commits[0].author.name }}")
# echo Last author $author_name
# echo "{author_name}={$author_name}" >> $GITHUB_OUTPUT
# - 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_name="${{ steps.author_name.outputs.author_name }}" --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:
# message: Updated leaderboard
# default_author: github_actions