generated from just-the-docs/just-the-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 1
76 lines (66 loc) · 2.73 KB
/
update_datasets.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Update Datasets and Create PR
on:
schedule:
- cron: '0 2 * * 7' # 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
if [ -n "$(git status -s)" ]; then
echo "Changes detected"
echo "changes_detected=true" >> $GITHUB_ENV
else
echo "changes_detected=false" >> $GITHUB_ENV
- 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: Install GitHub CLI
run: |
if ! command -v gh &> /dev/null
then
echo "GitHub CLI not found, installing..."
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh -y
else
echo "GitHub CLI is already installed."
fi
- name: Enable Auto-Merge for the PR
if: steps.git-check.outputs.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 }}