|
16 | 16 |
|
17 | 17 | permissions:
|
18 | 18 | contents: write
|
| 19 | + pull-requests: write # Grant permissions to create and manage pull requests |
19 | 20 |
|
20 | 21 | steps:
|
21 | 22 | - name: Checkout Stochtree Monorepo
|
@@ -51,15 +52,42 @@ jobs:
|
51 | 52 | run: |
|
52 | 53 | cp -r python_docs/_build/html/* docs/python-documentation/
|
53 | 54 |
|
54 |
| - - name: Commit and Push Documentation |
| 55 | + - name: Commit and Push Documentation to New Branch |
55 | 56 | run: |
|
56 | 57 | # Configure Git to use the GitHub actor for commits
|
57 | 58 | git config --global user.name "${{ github.actor }}"
|
58 | 59 | git config --global user.email "${{ github.actor }}@users.noreply.github.com"
|
59 | 60 |
|
| 61 | + # Create a new branch for the documentation update |
| 62 | + git checkout -b update-python-docs |
| 63 | +
|
60 | 64 | # Add the generated documentation, commit, and push
|
61 | 65 | git add docs/python-documentation
|
62 | 66 | git commit -m "Updated the Python documentation"
|
63 |
| - git push |
| 67 | + git push -u origin update-python-docs |
64 | 68 | env:
|
65 | 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 70 | + |
| 71 | + - name: Create Pull Request Using GitHub CLI |
| 72 | + run: | |
| 73 | + gh pr create --title "Updated the Python documentation" --body "This PR updates the Python documentation." --base main --head update-python-docs |
| 74 | + env: |
| 75 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + - name: Enable Auto-Merge on the PR |
| 78 | + run: | |
| 79 | + # Get the pull request number and enable auto-merge |
| 80 | + PR_NUMBER=$(gh pr list --head update-python-docs --json number --jq '.[0].number') |
| 81 | + gh pr merge $PR_NUMBER --auto --merge |
| 82 | + env: |
| 83 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + |
| 85 | + - name: Delete Branch After Merge |
| 86 | + if: success() # Only delete if previous steps were successful |
| 87 | + run: | |
| 88 | + # Delete the branch after the PR has been merged |
| 89 | + gh api repos/:owner/:repo/git/refs/heads/update-python-docs -X DELETE |
| 90 | + env: |
| 91 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + owner: ${{ github.repository_owner }} |
| 93 | + repo: ${{ github.event.repository.name }} |
0 commit comments