-
Notifications
You must be signed in to change notification settings - Fork 48
52 lines (49 loc) · 1.63 KB
/
generate.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
name: Run generate
on:
pull_request: # Temp change to test
pull_request_target:
workflow_dispatch:
permissions:
contents: write # Required for merging the PR
pull-requests: write # Required for managing pull requests
jobs:
generate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
cache: pip
- name: Run generate script
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
./generate.py
- name: Commit any changes
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if [[ $(git status --porcelain) ]]; then
git add .
git commit -m "Automated update from generate.py"
echo "Changes committed."
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "No changes to commit."
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.changes == 'true'
run: |
git push
gh pr comment ${{ github.event.pull_request.number }} \
--body "Automated changes were made by running \`generate.py\`. Please review the updates."
env:
GITHUB_TOKEN: ${{ secrets.COMMIT_TOKEN }}