Skip to content

Update Datasets and Create PR #52

Update Datasets and Create PR

Update Datasets and Create PR #52

name: Update Datasets and Create PR
on:
schedule:
- cron: '0 2 * * 0' # Runs at 02:00 UTC every Sunday
workflow_dispatch: # This line enables manual triggering of the workflow
jobs:
update-datasets:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetches all history for all branches and tags
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x' # Replace with the version you need
- name: Install dependencies
run: pip install requests pyyaml
- name: Run update_datasets.py
run: python ./scripts/update_datasets.py
- name: Check for changes
id: git-check
run: |
git diff
echo "git diff done"
if ! git diff --quiet; then
echo "Changes detected"
echo "changes_detected=true" >> "$GITHUB_ENV"
else
echo "changes_detected=false" >> "$GITHUB_ENV"
fi
echo "check done"
- name: Commit changes
if: env.changes_detected == 'true'
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "GitHub Action: Update datasets"
- name: Create Pull Request
if: env.changes_detected == 'true'
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
commit-message: "GitHub Action: Update datasets"
title: "[AUTO] Update Datasets"
body: "This is an auto-generated PR with dataset updates."
branch: "update-datasets-${{ github.run_number }}"
delete-branch: true
- name: Enable Auto-Merge for the PR
if: env.changes_detected == 'true'
run: |
PR_NUMBER=$(echo ${{ steps.create-pr.outputs.pull-request-number }})
gh pr merge $PR_NUMBER --auto --squash
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}