Skip to content

Commit

Permalink
[fix] github action opens PR instead of merging into main (#86)
Browse files Browse the repository at this point in the history
* [fix] github action opens PR instead of merging into main

* prevent new PR being made after mergining in the new version of the textbook
  • Loading branch information
ashmchiu authored Sep 7, 2024
1 parent f274c03 commit 7a7b920
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/generate-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
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

0 comments on commit 7a7b920

Please sign in to comment.