Skip to content

Commit

Permalink
Merge pull request #512 from jhudsl/pdfs-ugh
Browse files Browse the repository at this point in the history
Working on fixing some pdf rendering stuff
  • Loading branch information
avahoffman authored Jan 16, 2024
2 parents e8eeefa + c9fe299 commit c97ff16
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:

steps:
- name: Checkout files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:

steps:
- name: Checkout files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -188,7 +188,7 @@ jobs:

steps:
- name: checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Configure git
run: |
Expand Down Expand Up @@ -281,7 +281,7 @@ jobs:
# # Checks-out your repository with the token so your job can access it
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# get the full repo
fetch-depth: 0
Expand All @@ -302,7 +302,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
uses: tj-actions/changed-files@v41
# NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit.

- name: List all changed files
Expand All @@ -316,7 +316,7 @@ jobs:
run: Rscript -e "rmarkdown::clean_site(preview = FALSE)"

# Now we want to render all the html files from the Rmd files
- name: Run render html for the main site
- name: Run render html for the main website
id: site
run: Rscript -e "rmarkdown::render_site()"

Expand All @@ -325,7 +325,7 @@ jobs:
run: Rscript "scripts/render_module_details_for_syllabus.R"

# Render all module files
- name: Render html of modules
- name: Render html of modules where .Rmd has changed
run: |
Rscript --vanilla "scripts/render_modules.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
Expand All @@ -339,13 +339,14 @@ jobs:
run: |
Rscript --vanilla "scripts/render_resources.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
# Generate list of files that need pdfs
- name: Get list of html to pdfs
# Generate list of files that need pdfs
- name: Generate list of lectures that need pdfs generated
run: |
Rscript --vanilla "scripts/render_html_list.R"
echo the following need pdfs:
echo "$(cat files.txt)"
- name: Read html and pdf files
- name: Store list of lectures that need pdfs generated // Delete intermediate files
id: getfiles
run: |
echo "files=$(cat files.txt)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -441,7 +442,7 @@ jobs:
git config --global --add safe.directory /__w/$repo_name/$repo_name
- name: Checkout files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
Expand Down Expand Up @@ -472,7 +473,7 @@ jobs:
branch_name='preview-${{ github.event.pull_request.number }}'
git diff origin/main -- '*.pdf' >/dev/null && changes=true || changes=false
echo "changes=$changes" >> $GITHUB_OUTPUT
git add . --force
git add *.pdf --force
git commit -m 'Render preview' || echo "No changes to commit"
git pull --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours
git push --force || echo "No changes to commit"
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/render-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ on:
workflow_dispatch:
push:
branches: [ main, staging ]
paths:
- '**.Rmd'
- '**.md'

jobs:

Expand All @@ -33,7 +30,7 @@ jobs:
# # Checks-out your repository with the token so your job can access it
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# get the full repo
fetch-depth: 0
Expand All @@ -42,7 +39,7 @@ jobs:

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
uses: tj-actions/changed-files@v41
# NOTE: `since_last_remote_commit: true` is implied by default and falls back to the previous local commit.

- name: List all changed files
Expand Down Expand Up @@ -80,12 +77,13 @@ jobs:
Rscript --vanilla "scripts/render_resources.R" --files "${{ steps.changed-files.outputs.all_changed_files }}"
# Generate list of files that need pdfs
- name: Get list of html to pdfs
- name: Generate list of lectures that need pdfs generated
run: |
Rscript --vanilla "scripts/render_html_list.R"
echo the following need pdfs:
echo "$(cat files.txt)"
- name: Read html and pdf files
- name: Store list of lectures that need pdfs generated // Delete intermediate files
id: getfiles
run: |
echo "files=$(cat files.txt)" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -135,7 +133,7 @@ jobs:
git config --global --add safe.directory /__w/$repo_name/$repo_name
- name: Checkout files
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}
Expand All @@ -152,7 +150,7 @@ jobs:
run: |
git config --local user.email "[email protected]"
git config --local user.name "jhudsl-robot"
git add . --force
git add *.pdf --force
git commit -m 'Render pdfs' || echo "No changes to commit"
git pull --rebase --set-upstream origin main --allow-unrelated-histories --strategy-option=ours
git push --force || echo "No changes to commit"
9 changes: 9 additions & 0 deletions modules/Manipulating_Data_in_R/Manipulating_Data_in_R.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,12 @@ wide2
https://sebkrantz.github.io/collapse/

Might be helpful if your data is very large. However, `dplyr` and `tidyr` functions are great for most applications.









2 changes: 1 addition & 1 deletion scripts/render_html_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Read in all files needed

files <- readr::read_csv("lecture_files.csv")
files <- readr::read_csv("lecture_files.csv", show_col_types = FALSE)

if(nrow(files) > 0) {
files$files <- sapply(files$files, gsub, pattern = ".Rmd", replacement = "")
Expand Down

0 comments on commit c97ff16

Please sign in to comment.