Skip to content

Commit

Permalink
Update daily-commit-link.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunterdii authored Nov 6, 2024
1 parent 6d667b9 commit e7fc183
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/daily-commit-link.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Daily Commit Link and POTD Badge Tracker
on:
push:
branches:
- main # or your default branch name
- main # Trigger on push to main branch
schedule:
- cron: '0 0 * * *' # This will run daily at midnight UTC
workflow_dispatch:
workflow_dispatch: # Allows manual triggering

jobs:
update-link:
Expand All @@ -23,8 +23,21 @@ jobs:
- name: Install requests
run: pip install requests

- name: Get latest solution commit
id: latest_commit
run: |
# Fetch the latest commit from the repository
COMMIT_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/commits?sha=main&per_page=1")
# Extract the filename of the solution from the commit message
FILE_NAME=$(echo $COMMIT_DATA | jq -r '.[0].commit.message' | grep -oP '\d{2}\(.*\).md')
# Set an output to pass to the next step
echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
- name: Update README with the Latest Commit
run: python src/update_commit.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} README.md
run: python src/update_commit.py ${{ github.repository }} ${{ secrets.GITHUB_TOKEN }} README.md ${{ env.FILE_NAME }}

- name: Commit and Push Changes
run: |
Expand Down

0 comments on commit e7fc183

Please sign in to comment.