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

[fix] remove dynamic branch naming

[fix] remove temporary files (#88)
  • Loading branch information
ashmchiu committed Sep 7, 2024
1 parent f274c03 commit be1fa35
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/generate-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,40 @@ jobs:
"pdf_output/network_abusing-intrusion-detection.pdf" \
"pdf_output/network_malware.pdf" \
"pdf_output/network_tor.pdf" \
"textbook_full_tmp.pdf"
"textbook_full.pdf"
- name: Inject page numbers back into the pdf
run: pdfjam --pagecommand '\pagestyle{plain}' --outfile textbook_full.pdf textbook_full_tmp.pdf
run: pdfjam --pagecommand '\pagestyle{plain}' --outfile textbook_full.pdf textbook_full.pdf

- name: Remove temporary files
run: |
rm -rf pdf_output
- name: Upload PDF as an artifact
uses: actions/upload-artifact@v4
with:
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
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
title: "Update full PDF of textbook"
body: "This PR updates the full PDF of the textbook."
base: main

0 comments on commit be1fa35

Please sign in to comment.