diff --git a/.github/workflows/generate-pdf.yml b/.github/workflows/generate-pdf.yml index 240e501..c73cba5 100644 --- a/.github/workflows/generate-pdf.yml +++ b/.github/workflows/generate-pdf.yml @@ -140,13 +140,25 @@ jobs: name: textbook-full path: textbook_full.pdf - - name: Commit and push changes only on push - if: github.event_name == 'push' + - name: Commit changes to a new branch + if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Update PDF of textbook') run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "GitHub Actions" + git checkout -b update-textbook-full-pdf-$(date +%s) git add textbook_full.pdf - git commit -m "Update full PDF of textbook on site" - git push + git commit -m "Update PDF of textbook on site after a merge to main" + git push origin HEAD env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create a Pull Request + if: github.event_name == 'push' && !contains(github.event.head_commit.message, 'Update PDF of textbook') + uses: peter-evans/create-pull-request@v5 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update PDF of textbook on site" + branch: update-textbook-full-pdf-$(date +%s) + title: "Update full PDF of textbook" + body: "This PR updates the full PDF of the textbook." + base: main