-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move generate to its own workflow and create commits
- Loading branch information
${GIT_USER_NAME}
authored and
${GIT_USER_NAME}
committed
Jan 6, 2025
1 parent
b76293a
commit e5655b2
Showing
2 changed files
with
55 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Run generate | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- synchronize | ||
- reopened | ||
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.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters