Skip to content

Commit

Permalink
Merge c78a384 into 4b1e727
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy authored Jan 26, 2024
2 parents 4b1e727 + c78a384 commit 7c7e80b
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

# Check out current repository
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

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

- name: Login as jhudsl-robot
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:

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

- name: Verify Dockerfiles changed?
uses: tj-actions/verify-changed-files@v8.8
uses: tj-actions/verify-changed-files@v17
id: verify-changed-files
with:
files: |
Expand Down
53 changes: 19 additions & 34 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_PAT }}

# Use the yaml-env-action action.
- name: Load environment from YAML
Expand All @@ -31,23 +32,24 @@ jobs:
# Make the branch fresh
- name: Make the branch fresh
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.email "itcrtrainingnetwork@gmail.com"
git config --global user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
echo branch doesnt exist
git checkout -b $branch_name || echo branch exists
git push --set-upstream origin $branch_name
shell: bash


outputs:
toggle_spell_check: "${{ env.SPELL_CHECK }}"
toggle_style_code: "${{ env.STYLE_CODE }}"
toggle_url_check: "${{ env.URL_CHECKER }}"
toggle_quiz_check: "${{ env.CHECK_QUIZZES }}"
toggle_render_preview: "${{ env.RENDER_PREVIEW }}"
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
render_student_guide: "${{ env.RENDER_STUDENT_GUIDE }}"

########################## Make the error reports ##############################
spell-check:
Expand All @@ -59,6 +61,7 @@ jobs:
check_type: spelling
error_min: 3
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}

url-check:
name: Check URLs
Expand All @@ -69,6 +72,7 @@ jobs:
check_type: urls
error_min: 0
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}

quiz-check:
name: Check quiz formatting
Expand All @@ -79,6 +83,7 @@ jobs:
check_type: quiz_format
error_min: 0
gh_pat: secrets.GH_PAT
branch_name: ${GITHUB_HEAD_REF}

############################# Style the code ###################################
style-code:
Expand All @@ -91,7 +96,7 @@ jobs:

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

Expand All @@ -117,47 +122,27 @@ jobs:

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

# Set up git checkout
- name: Set up git checkout
run: |
git config --system --add safe.directory "$GITHUB_WORKSPACE"
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
git config --global --add safe.directory $GITHUB_WORKSPACE
git config --global user.email "itcrtrainingnetwork@gmail.com"
git config --global user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories
shell: bash

# Make sure the link for AnVIL feedback is prepopulated for the specific course
- name: Set up feedback link
id: feedback
run: bash scripts/AnVIL_Feedback_Script.sh


# Run bookdown rendering
- name: Run bookdown render
id: bookdown
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"

# Render a student guide if specified. This is a bit clunky because
# Bookdown does not work well if the files aren't named as such in the
# root directory
- name: Run student guide render
if: ${{needs.yaml-check.outputs.render_student_guide == 'yes'}}
id: student_guide
run: |
mkdir tmp1
mv _bookdown.yml _output.yml tmp1
mv student-guide/_bookdown.yml student-guide/_output.yml .
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
mv _bookdown.yml _output.yml student-guide
mv tmp1/_bookdown.yml tmp1/_output.yml .
rm -r tmp1

# Run TOC-less version
# Rendered content for Leanpub and Coursera is very similar.
Expand Down Expand Up @@ -199,13 +184,13 @@ jobs:
- name: Build components of the comment
id: build-components
run: |
course_name=$(head -n 1 student-guide/_bookdown.yml | cut -d'"' -f 2| tr " " "-")
course_name=$(head -n 1 _bookdown.yml | cut -d'"' -f 2| tr " " "-")
bookdown_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/index.html")
tocless_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/no_toc/index.html")
student_docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/student-guide/$course_name.docx")
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT
echo "tocless_link=$tocless_link" >> $GITHUB_OUTPUT
echo "student_docx_link=$student_docx_link" >> $GITHUB_OUTPUT
echo "docx_link=$docx_link" >> $GITHUB_OUTPUT
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo ${{steps.commit.outputs.changes}}
Expand All @@ -220,7 +205,7 @@ jobs:
Re-rendered previews from the latest commit:
- See [preview of Bookdown here](${{ steps.build-components.outputs.bookdown_link }})
- See [preview of Coursera/Leanpub version here](${{ steps.build-components.outputs.tocless_link }})
- Download the [preview of the Student Guide .docx file](${{ steps.build-components.outputs.student_docx_link }})
- Download the [preview of .docx file](${{ steps.build-components.outputs.docx_link }})
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
Expand Down
Loading

0 comments on commit 7c7e80b

Please sign in to comment.