-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (58 loc) · 1.86 KB
/
automatically-update-readme.yaml
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
name: Automatically update README
on:
workflow_dispatch:
schedule:
- cron: "0 0 1 * *"
push:
branches:
- main
env:
BRANCH_HEADER: "bot/update-readme-"
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: pip install -e .[dev]
- name: Run script
run: |
python update_readme.py > README.md
- name: Check if README.md has changed
id: check_changes
run: |
if [[ -n $(git status --porcelain README.md) ]]; then
echo "README.md has changed."
echo "changes_detected=true" >> "$GITHUB_ENV"
else
echo "README.md has not changed."
echo "changes_detected=false" >> "$GITHUB_ENV"
fi
- name: Commit changes
if: env.changes_detected == 'true'
run: |
git checkout -b ${BRANCH_HEADER}${{ github.run_id }}
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "Update README.md"
- name: Push changes
if: env.changes_detected == 'true'
run: git push -u origin ${BRANCH_HEADER}${{ github.run_id }}
- name: Create pull request
if: env.changes_detected == 'true'
run: |
gh pr create \
--title "Update README.md" \
--body "This PR updates the README.md file." \
--base main \
--head ${BRANCH_HEADER}${{ github.run_id }} \
--reviewer hmasdev \
--assignee hmasdev \
--label "bot"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}