Skip to content

Commit

Permalink
Merge 22a4ab4 into ec24b16
Browse files Browse the repository at this point in the history
  • Loading branch information
cansavvy authored Feb 3, 2022
2 parents ec24b16 + 22a4ab4 commit 28c0396
Show file tree
Hide file tree
Showing 44 changed files with 2,360 additions and 101 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/course-content-add.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ name: New content idea
about: Suggest an idea for the course
title: ''
labels: ''
assignees: cansavvy
assignees:

---

**Describe the your scope of your content idea**
What will this cover and how does it relate to the current course material?
## Describe the your scope of your content idea
<!-- What will this cover and how does it relate to the current course material? -->

**Describe the learning objectives for your content idea**
What will users learn from this new content?
## Describe the learning objectives for your content idea
<!-- What will users learn from this new content? -->

**Additional context or resources**
Add any other context or related resources we should know about?
## Additional context or resources
<!-- Add any other context or related resources we should know about? -->
25 changes: 13 additions & 12 deletions .github/ISSUE_TEMPLATE/course-problem-report.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
---
name: Course Problem Report
about: Create a report to help improve the course
title: problem
title: [Problem]
labels: bug
assignees: cansavvy
assignees:

---

**Describe what is not working with the course**
A clear and concise description of what the bug is.
## Describe what is not working with the course
<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
Steps to reproduce the behavior:
## Steps to Reproduce
<!-- Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
-->

**Expected behavior**
A clear and concise description of what you expected to happen.
## Expected behavior
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**
If applicable, add screenshots to help explain your problem.
## Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->

**Additional context**
Add any other context about the problem here.
## Additional context
<!-- Add any other context about the problem here. -->
1 change: 1 addition & 0 deletions .github/workflows/delete-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
build-all:
runs-on: ubuntu-latest
steps:

# This is because if a PR is closed before a render finishes it won't find it.
- name: Sleep for 5 minutes
run: sleep 300s
Expand Down
15 changes: 10 additions & 5 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: checkout repo
uses: actions/checkout@v2

- name: login as jhudsl-robot
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
- name: Don't re-test if this is a sync branch
if: ${{ github.head_ref == 'repo-sync/DaSL_Course_Template_Bookdown/default' }}
if: ${{ github.head_ref == 'repo-sync/OTTR_Template/default' }}
run: |
echo This was tested on DaSL_Course_Template_Bookdown no need to re-run
echo This was tested on OTTR_Template no need to re-run
exit 1
# Set up Docker build
Expand Down Expand Up @@ -93,5 +98,5 @@ jobs:
- name: Push Docker image if release
if: ${{ github.event_name == 'release' }}
run: |
docker tag jhudsl/course_template jhudsl/course_template:${{ steps.get_version.outputs.version }}
docker tag jhudsl/course_template:latest jhudsl/course_template:${{ steps.get_version.outputs.version }}
docker push jhudsl/course_template:1.0
12 changes: 6 additions & 6 deletions .github/workflows/release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: mshick/add-pr-comment@v1
if: ${{ github.head_ref == 'repo-sync/DaSL_Course_Template_Bookdown/default' }}
if: ${{ github.head_ref == 'repo-sync/OTTR_Template/default' }}
with:
message: |
**Please carefully review these changes and decide which are useful for your course.**
See the release notes: https://github.com/jhudsl/DaSL_Course_Template_Bookdown/releases
See the release notes: https://github.com/jhudsl/OTTR_Template/releases
- If you don't want the changes from a particular file, you can always [revert that particular commit](https://git-scm.com/docs/git-revert) before merging the sync PR.
If you will not want any updates on this file in the future, you may want to remove a file from being synced in your repo [by reconfiguring the sync file](https://github.com/jhudsl/DaSL_Course_Template_Bookdown/blob/main/.github/sync.yml).
If you will not want any updates on this file in the future, you may want to remove a file from being synced in your repo [by reconfiguring the sync file](https://github.com/jhudsl/OTTR_Template/blob/main/.github/sync.yml).
- If you want only some changes, but they are not on a whole file basis, you could check out the branch and make manual edits. To checkout the branch, navigate to your own repository you should be able to run:
```
git checkout repo-sync/DaSL_Course_Template_Bookdown/default
git checkout repo-sync/OTTR_Template/default
```
- If you don't want any of the changes you can close the PR entirely.
You may want to unenroll your repository from the sync GitHub actions by [filing a PR](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) on `DaSL_Course_Template_Bookdown`
to delete [your repo name from this file](https://github.com/jhudsl/DaSL_Course_Template_Bookdown/blob/main/.github/sync.yml) if this will continue to be the case.
You may want to unenroll your repository from the sync GitHub actions by [filing a PR](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) on `OTTR_Template`
to delete [your repo name from this file](https://github.com/jhudsl/OTTR_Template/blob/main/.github/sync.yml) if this will continue to be the case.
repo-token: ${{ secrets.GH_PAT }}
repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/render-bookdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ on:
branches: [ main ]
paths:
- '**.Rmd'
- docker/Dockerfile
- docker/*
- assets/*
jobs:
# This workflow contains a single job called "build-all"
build-all:
# The type of runner that the job will run on
render-main:
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
Expand Down Expand Up @@ -67,31 +67,45 @@ jobs:

###### END OF DOCKER UPDATE CHUNK ##############################################

# We want a fresh run of the renders each time
- name: Delete old docs/*
run: rm -r docs/*

# Run bookdown rendering
- name: Run bookdown render
id: bookdown
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "bookdown::render_book('index.Rmd')"
Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"
##### If you do not wish to host your course on Coursera, you can delete this section #####
# Run Coursera version
- name: Run Coursera version of render
id: coursera
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "leanbuild::render_coursera()"
Rscript -e "ottr::render_coursera()"
##### End of Coursera rendering section ########################################

# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
- name: Check on render steps
if: steps.bookdown.outcome != 'success' || steps.coursera.outcome != 'success'
run: |
echo Bookdown status ${{steps.bookdown.outcome}}
echo Coursera status ${{steps.coursera.outcome}}
exit 1
# Commit the rendered bookdown files
- name: Commit rendered bookdown files
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add -A
git add --force docs/*
git commit -m 'Render bookdown' || echo "No changes to commit"
git push origin main || echo "No changes to push"
101 changes: 77 additions & 24 deletions .github/workflows/render-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,110 @@ on:
pull_request:
branches: [ main ]

permissions: write-all

jobs:
# This workflow contains a single job called "build-all"
build-all:
# The type of runner that the job will run on
render-preview:
runs-on: ubuntu-latest
container:
image: jhudsl/course_template
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout
- name: Checkout files
uses: actions/checkout@v2
with:
# get the full repo
fetch-depth: 0
# use github PAT
token: ${{ secrets.GH_PAT }}

# Set up git checkout
- name: Set up git checkout
run: |
git config --local user.email "itcrtrainingnetwork@gmail.com"
git config --local user.name "jhudsl-robot"
branch_name='preview-${{ github.event.pull_request.number }}'
exists=$(git ls-remote https://${{ secrets.GH_PAT }}@github.com/$GITHUB_REPOSITORY $branch_name | wc -l | xargs)
if [[ $exists == 0 ]];then
echo branch doesnt exist
git checkout -b $branch_name
git push --set-upstream origin $branch_name
else
echo branch does exist
git fetch --all
git checkout $branch_name
git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }}
fi
rm -r docs/*
shell: bash

# Run bookdown rendering
- name: Run bookdown render
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "bookdown::render_book('index.Rmd')"
id: bookdown
run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')"

##### If you do not wish to host your course on Coursera, you can delete this section #####
# Run Coursera version
- name: Run Coursera version of render
run: |
docker run \
--mount type=bind,target=/home/rstudio,source=$PWD \
jhudsl/course_template \
Rscript -e "leanbuild::render_coursera()"
id: coursera
run: Rscript -e "ottr::render_coursera()"

##### End of Coursera rendering section ########################################

# This checks on the steps before it and makes sure that they completed.
# If the renders didn't complete we don't want to commit the file changes
- name: Check on render steps
if: steps.bookdown.outcome != 'success' || steps.coursera.outcome != 'success'
run: |
echo Bookdown status ${{steps.bookdown.outcome}}
echo Coursera status ${{steps.coursera.outcome}}
exit 1
# Commit the rendered bookdown files
- name: Commit rendered bookdown files to development branch
- name: Commit rendered bookdown files to preview branch
id: commit
run: |
git checkout -b "preview-${{ github.event.pull_request.number }}"
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add -A
git commit -m 'Render bookdown preview' || echo "No changes to commit"
git push --force origin "preview-${{ github.event.pull_request.number }}" || echo "No changes to push"
branch_name='preview-${{ github.event.pull_request.number }}'
git diff --name-only origin/main -- docs >/dev/null && changes=true || changes=false
echo $changes
if $changes == true; then
echo ::set-output name=changes::$(echo 'changes')
git diff --name-only origin/$branch_name -- docs/ >/dev/null && changes=true || changes=false
echo $changes
if $changes == true; then
git add . --force
git commit -m 'Render bookdown preview'
git pull --set-upstream origin $branch_name --allow-unrelated-histories
git push
fi
fi
shell: bash

- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Re-rendered
body-includes: latest commit

- name: Build components of the comment
id: build-components
run: |
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")
coursera_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/docs/coursera/index.html")
docx_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/docs/$course_name.docx")
echo ::set-output name=bookdown_link::$bookdown_link
echo ::set-output name=coursera_link::$coursera_link
echo ::set-output name=docx_link::$docx_link
echo ::set-output name=time::$(date +'%Y-%m-%d')
echo ::set-output name=commit_id::$GITHUB_SHA
echo ${{steps.commit.outputs.changes}}
- name: Create or update comment
if: steps.commit.outputs.changes == 'changes'
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
Expand All @@ -79,6 +119,19 @@ jobs:
Re-rendered previews from the latest commit:
- See [preview of Bookdown here](${{ steps.build-components.outputs.bookdown_link }})
- See [preview of Coursera version here](${{ steps.build-components.outputs.coursera_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

- name: No comment if no changes
if: steps.commit.outputs.changes == 'no_changes'
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
The latest commit did not produce rendering changes.
_Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
Loading

0 comments on commit 28c0396

Please sign in to comment.