diff --git a/.github/sync.yml b/.github/sync.yml index 540f29b..d0f474c 100644 --- a/.github/sync.yml +++ b/.github/sync.yml @@ -11,32 +11,104 @@ group: test-send-updates.yml starting-course.yml release-notes.yml - - source: .github/workflows/delete-preview.yml - dest: .github/workflows/docker-test.yml - - source: .github/workflows/pull_request.yml - dest: .github/workflows/render-site.yml - - source: config_automation.yml - dest: config_automation.yml + docker-test.yml + docker-build.yml + - source: scripts/ + dest: scripts/ + deleteOrphaned: true + - source: .github/ISSUE_TEMPLATE/course-problem-report.md + dest: .github/ISSUE_TEMPLATE/course-problem-report.md + - source: .github/ISSUE_TEMPLATE/course-content-add.md + dest: .github/ISSUE_TEMPLATE/course-content-add.md + - source: style-sets + dest: style-sets + - source: assets/box_images/ + dest: assets/box_images/ # Repositories to receive changes repos: | - jhudsl/ottr-website - jhudsl/Baltimore_Community_Course - maculatus/test-ottr-website - dr-sayyadhury/OTTR_Template_Website_repo - whalera1901/Current-projects - GenetcXBiotech1/Dr.Fierst_lab - buriedsand/glbio-personal-website - PurplFeesh/test-ottr-site - jcha40/ottr_test_site + jhudsl/Documentation_and_Usability + jhudsl/Informatics_Research_Leadership + jhudsl/Data_Management_for_Cancer_Research + jhudsl/Computing_for_Cancer_Informatics + jhudsl/Adv_Reproducibility_in_Cancer_Informatics + jhudsl/Reproducibility_in_Cancer_Informatics + jhudsl/Dissemination_and_Engagement + jhudsl/Cancer_Clinical_Informatics + jhudsl/Machine_Learning_for_Cancer_Informatics + jhudsl/Cancer_Informatics_Data_Visualization + jhudsl/Cancer_Genome_Informatics + jhudsl/Cancer-Imaging-Informatics + datatrail-jhu/DataTrail_Template + abyzovlab/CNVpytor-course + opencasestudies/OCS_Guide + tmm211/dsp-terra-mooc-test2 + fhdsl/Choosing_Genomics_Tools + fhdsl/NIH_Data_Sharing + fhdsl/FH_Cluster_Guide + fhdsl/Using_Leanpub + fhdsl/Ethical_Data_Handling_for_Cancer_Research + fhdsl/Overleaf_and_LaTeX_for_Scientific_Articles + fhdsl/Design_of_Data_Analysis + fhdsl/Tools_for_Reproducible_Workflows_in_R + fhdsl/Introduction_to_reproducible_research + mccoy-lab/hgv_modules + griffithlab/pVACtools_Intro_Course + griffithlab/CIVIC_SVI_Course + PracticalGenomics/cogaps-on-sciserver + fhdsl/AI_for_software + griffithlab/Immuno_Workflow_Course + ###ADD NEW REPO HERE following the format above# -### These are custom groups for syncing -- not all files needs to be synced # will update later - # - files: - # - source: config_automation.yml - # dest: config_automation.yml - # - source: .github/workflows/pull-request.yml - # dest: .github/workflows/pull-request.yml - # - source: scripts/spell-check.R - # dest: scripts/spell-check.R - # repos: | - # jhudsl/Baltimore_Community_Course +### These are custom groups for syncing -- not all files needs to be synced + - files: + - source: config_automation.yml + dest: config_automation.yml + - source: .github/workflows/pull-request.yml + dest: .github/workflows/pull-request.yml + repos: | + jhudsl/OTTR_Template_Website + + - files: + - source: config_automation.yml + dest: config_automation.yml + - source: .github/workflows/delete-preview.yml + dest: .github/workflows/delete-preview.yml + - source: .github/workflows/send-updates.yml + dest: .github/workflows/send-updates.yml + - source: .github/workflows/test-send-updates.yml + dest: .github/workflows/test-send-updates.yml + - source: scripts/make_screenshots.R + dest: scripts/make_screenshots.R + - source: scripts/switch_sync_repo.R + dest: scripts/switch_sync_repo.R + repos: | + jhudsl/OTTR_Quizzes + + - files: + - source: .github/workflows/ + dest: .github/workflows/ + exclude: | + starting-course.yml + release-notes.yml + - source: .github/switch_sync_repo.R + dest: .github/switch_sync_repo.R + - source: .github/ISSUE_TEMPLATE/course-problem-report.md + dest: .github/ISSUE_TEMPLATE/course-problem-report.md + - source: .github/ISSUE_TEMPLATE/course-content-add.md + dest: .github/ISSUE_TEMPLATE/course-content-add.md + - source: code_of_conduct.md + dest: code_of_conduct.md + - source: assets/box_images/ + dest: assets/box_images/ + - source: assets/style.css + dest: assets/style.css + - source: assets/toc_close.css + dest: assets/toc_close.css + - source: scripts/ + dest: scripts/ + deleteOrphaned: true + - source: style-sets/fhdasl/ + dest: style-sets/fhdasl/ + repos: | + jhudsl/AnVIL_Template diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..77491cb --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,79 @@ +# Candace Savonen Apr 2021 + +name: Build Docker + +on: + workflow_dispatch: + inputs: + dockerhubpush: + description: 'Push to Dockerhub?' + required: true + default: 'false' + tag: + description: 'What tag to use?' + required: true + default: 'none' +jobs: + build-docker: + name: Build Docker image + runs-on: ubuntu-latest + + steps: + - name: checkout repo + uses: actions/checkout@v3 + + - name: Login as jhudsl-robot + run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" + 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 + run: | + echo This was tested on OTTR_Template no need to re-run + + # Set up Docker build + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + # Setup layer cache + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + # Set up Docker build + - name: Set up Docker Build + if: ${{ github.head_ref != 'repo-sync/OTTR_Template/default' }} + uses: docker/setup-buildx-action@v1 + + - name: Get token + run: echo ${{ secrets.GH_PAT }} > docker/git_token.txt + + # Build docker image + - name: Build Docker image + uses: docker/build-push-action@v2 + with: + push: false + load: true + context: docker + file: docker/Dockerfile + tags: jhudsl/base_ottr + + # Login to Dockerhub + - name: Login to DockerHub + if: ${{ github.event.inputs.dockerhubpush != 'false' }} + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Push the Docker image if set to true from a manual trigger + - name: Push Docker image if manual trigger set to true + if: ${{ github.event.inputs.dockerhubpush != 'false' }} + run: | + docker tag jhudsl/base_ottr:latest jhudsl/base_ottr:$github.event.inputs.tag + docker push jhudsl/base_ottr:$github.event.inputs.tag diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 6d786f4..e1eab59 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -45,6 +45,7 @@ jobs: - name: Login as jhudsl-robot run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" git config --local user.email "itcrtrainingnetwork@gmail.com" git config --local user.name "jhudsl-robot" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e52060a..9316682 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,6 @@ -# Candace Savonen Dec 2021 -# Updated April 2023 +# Candace Savonen 2021 +# Updated Jan 2023 + name: Pull Request on: @@ -30,18 +31,21 @@ 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: - public_repository: "${{ steps.public_repository.outputs.public }}" 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 }}" @@ -66,12 +70,49 @@ jobs: error_min: 0 gh_pat: secrets.GH_PAT + quiz-check: + name: Check quiz formatting + if: ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}} + needs: yaml-check + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main + with: + check_type: quiz_format + error_min: 0 + gh_pat: secrets.GH_PAT + +############################# Style the code ################################### + style-code: + name: Style code + needs: yaml-check + runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_style_code == 'yes'}} + container: + image: jhudsl/base_ottr:main + + steps: + - name: Checkout files + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Run styler + run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()" + + - name: Commit styled files + run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" + git add \*.Rmd + git commit -m 'Style Rmds' || echo "No changes to commit" + git push origin || echo "No changes to commit" + +############################# Render Preview ################################### + render-preview: name: Render preview needs: yaml-check runs-on: ubuntu-latest container: - image: jhudsl/course_template:main + image: ${{needs.yaml-check.outputs.rendering_docker_image}} if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}} steps: @@ -83,9 +124,9 @@ jobs: # 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 @@ -93,35 +134,34 @@ jobs: git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories shell: bash - # We want a fresh run of the renders each time - so first delete old html files - - name: Delete old *.html - 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 - id: site - run: Rscript -e "rmarkdown::render_site()" + # Run bookdown rendering + - name: Run bookdown render + id: bookdown + run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')" - # We may have html files that we want to render to add as links on the pages -these will be stored in a dir called subdir_html - - name: Render subdir_html - id: subdir_html - run: Rscript -e "for (i in list.files(path = './subdir_html', pattern = 'Rmd$', recursive = TRUE, full.names = TRUE)){rmarkdown::render(i)}" + # Run TOC-less version + # Rendered content for Leanpub and Coursera is very similar. + # This job creates a shared scaffold for both. + - name: Run TOC-less version of render + id: tocless + run: Rscript -e "ottrpal::render_without_toc()" # 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.site.outcome != 'success' + if: steps.bookdown.outcome != 'success' || steps.tocless.outcome != 'success' run: | - echo site status ${{steps.site.outcome}} + echo Bookdown status ${{steps.bookdown.outcome}} + echo Toc-less status ${{steps.tocless.outcome}} exit 1 - # Commit the rendered website files - - name: Commit rendered website files to preview branch + # Commit the rendered bookdown files + - name: Commit rendered bookdown files to preview branch id: commit run: | branch_name='preview-${{ github.event.pull_request.number }}' - git diff origin/main -- '*.html' >/dev/null && changes=true || changes=false - echo ::set-output name=changes::$changes + git diff origin/main -- docs >/dev/null && changes=true || changes=false + echo "changes=$changes" >> $GITHUB_OUTPUT git add . --force git commit -m 'Render preview' || echo "No changes to commit" git pull --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours @@ -129,7 +169,7 @@ jobs: shell: bash - name: Find Comment - uses: peter-evans/find-comment@v1 + uses: peter-evans/find-comment@v2 id: fc with: issue-number: ${{ github.event.pull_request.number }} @@ -139,28 +179,35 @@ jobs: - name: Build components of the comment id: build-components run: | - course_name=$(head -n 1 _website.yml | cut -d'"' -f 2| tr " " "-") - website_link=$(echo "https://htmlpreview.github.io/?https://raw.githubusercontent.com/$GITHUB_REPOSITORY/preview-${{ github.event.pull_request.number }}/index.html") - echo ::set-output name=website_link::$website_link - echo ::set-output name=time::$(date +'%Y-%m-%d') - echo ::set-output name=commit_id::$GITHUB_SHA + 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") + 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 "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}} - name: Create or update comment if: steps.commit.outputs.changes == 'true' - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@v2 with: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} body: | - Re-rendered previews from the latest commit: See [preview of website here](${{ steps.build-components.outputs.website_link }}) + 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 .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 + - name: Comment if no changes if: steps.commit.outputs.changes == 'false' - uses: peter-evans/create-or-update-comment@v1 + uses: peter-evans/create-or-update-comment@v2 with: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/release-notes.yml b/.github/workflows/release-notes.yml new file mode 100644 index 0000000..d76e0e2 --- /dev/null +++ b/.github/workflows/release-notes.yml @@ -0,0 +1,35 @@ +# Candace Savonen Sept 2021 + +name: Release note PR comment + +on: + pull_request: + branches: [ main, staging ] + types: [ opened ] + +jobs: + pr-comment: + runs-on: ubuntu-latest + steps: + + - uses: mshick/add-pr-comment@v1 + 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/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/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/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 `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-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens + allow-repeats: false # This is the default diff --git a/.github/workflows/render-all.yml b/.github/workflows/render-all.yml new file mode 100644 index 0000000..083817a --- /dev/null +++ b/.github/workflows/render-all.yml @@ -0,0 +1,242 @@ + +# Candace Savonen Apr 2021 + +name: Render all output courses + +on: + workflow_dispatch: + push: + branches: [ main, staging ] + paths: + - '**.Rmd' + - assets/* + +jobs: + + yaml-check: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + # Use the yaml-env-action action. + - name: Load environment from YAML + uses: doughepi/yaml-env-action@v1.0.0 + with: + files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. + outputs: + toggle_bookdown: "${{ env.RENDER_BOOKDOWN }}" + toggle_coursera: "${{ env.RENDER_COURSERA }}" + toggle_leanpub: "${{ env.RENDER_LEANPUB }}" + make_book_txt: "${{ env.MAKE_BOOK_TXT }}" + rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" + toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" + + render-bookdown: + name: Render bookdown + needs: yaml-check + runs-on: ubuntu-latest + container: + image: ${{needs.yaml-check.outputs.rendering_docker_image}} + if: ${{needs.yaml-check.outputs.toggle_bookdown == 'yes'}} + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + + # We want a fresh run of the renders each time + - name: Delete old docs/* + run: rm -rf docs/* + + # Run bookdown rendering + - name: Run bookdown render + id: bookdown + run: | + Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all'); + file.copy(from = 'assets', to = 'docs/assets', overwrite = TRUE)" + + # 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 step + if: steps.bookdown.outcome != 'success' + run: | + echo Bookdown status ${{steps.bookdown.outcome}} + exit 1 + + # Commit the rendered bookdown files + - name: Commit rendered bookdown files + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git add --force docs/* + git commit -m 'Render bookdown' || echo "No changes to commit" + git pull --allow-unrelated-histories --strategy-option=ours + git push -u origin main || echo "No changes to push" + + render-tocless: + name: Render TOC-less version for Leanpub or Coursera + needs: [yaml-check] + runs-on: ubuntu-latest + container: + image: ${{needs.yaml-check.outputs.rendering_docker_image}} + if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes' || needs.yaml-check.outputs.toggle_leanpub == 'yes'}} + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + + # Rendered content for Leanpub and Coursera is very similar. + # This job creates a shared scaffold for both. + - name: Run TOC-less version of render + id: tocless + run: Rscript -e "ottrpal::render_without_toc()" + + # Commit the TOC-less version files + - name: Commit tocless bookdown files + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git add --force docs/no_toc* + git commit -m 'Render toc-less' || echo "No changes to commit" + git pull --allow-unrelated-histories --strategy-option=ours + git push -u origin main || echo "No changes to push" + + render-leanpub: + name: Finish Leanpub prep + needs: [yaml-check, render-tocless] + runs-on: ubuntu-latest + container: + image: jhudsl/ottrpal:main + if: ${{needs.yaml-check.outputs.toggle_leanpub == 'yes'}} + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + + # Create screenshots + - name: Run the screenshot creation + run: | + # Remove old folder + rm -rf resources/chapt_screen_images + + # Make new screenshots + chapt_urls=$(Rscript --vanilla scripts/make_screenshots.R \ + --git_pat ${{ secrets.GH_PAT }} \ + --repo $GITHUB_REPOSITORY \ + --output_dir resources/chapt_screen_images) + + # We want a fresh run of the renders each time + - name: Delete manuscript/ + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + rm -rf manuscript/ + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git add . + git commit -m 'Delete manuscript folder' || echo "No changes to commit" + git pull --allow-unrelated-histories --strategy-option=ours + git push -u origin main || echo "No changes to push" + + - name: Run ottrpal::bookdown_to_embed_leanpub + if: needs.yaml-check.outputs.toggle_quiz_check == 'no' + run: | + Rscript -e "ottrpal::bookdown_to_embed_leanpub( + render = FALSE, \ + chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ + make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'), \ + quiz_dir = NULL)" + + - name: Run ottrpal::bookdown_to_embed_leanpub + if: needs.yaml-check.outputs.toggle_quiz_check == 'yes' + run: | + Rscript -e "ottrpal::bookdown_to_embed_leanpub( + render = FALSE, \ + chapt_img_key = 'resources/chapt_screen_images/chapter_urls.tsv', \ + make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt}}'))" + + # Commit the rendered Leanpub files + - name: Commit rendered Leanpub files + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + mkdir -p manuscript + git add --force manuscript/* + git add --force resources/* + git add --force docs/* + git commit -m 'Render Leanpub' || echo "No changes to commit" + git pull --allow-unrelated-histories --strategy-option=ours + git push --force --set-upstream origin main || echo "No changes to push" + + render-coursera: + name: Finish Coursera prep + needs: [yaml-check, render-tocless] + runs-on: ubuntu-latest + container: + image: ${{needs.yaml-check.outputs.rendering_docker_image}} + if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes'}} + + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + + # Run Coursera version + - name: Convert Leanpub quizzes to Coursera + if: needs.yaml-check.outputs.toggle_leanpub == 'yes' && needs.yaml-check.outputs.toggle_quiz_check == 'yes' + id: coursera + run: Rscript -e "ottrpal::convert_coursera_quizzes()" + + # Commit the rendered bookdown files + - name: Commit rendered Coursera files + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git add --force manuscript/* + git add --force resources/* + git add --force docs/* + git commit -m 'Render Coursera quizzes' || echo "No changes to commit" + git pull --allow-unrelated-histories --strategy-option=ours + git push -u origin main || echo "No changes to push" diff --git a/.github/workflows/send-updates.yml b/.github/workflows/send-updates.yml index efceda2..3fda233 100644 --- a/.github/workflows/send-updates.yml +++ b/.github/workflows/send-updates.yml @@ -18,13 +18,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@master + uses: actions/checkout@v3 - name: Login as jhudsl-robot 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" - name: Get the version id: get_tag diff --git a/.github/workflows/starting-course.yml b/.github/workflows/starting-course.yml new file mode 100644 index 0000000..d1683f2 --- /dev/null +++ b/.github/workflows/starting-course.yml @@ -0,0 +1,138 @@ +# Code adapted from https://github.com/JetBrains/intellij-platform-plugin-template/blob/deb171483598ee8a5d7621154db880e87b4db4ef/.github/workflows/template-cleanup.yml +# by Candace Savonen for this repository. + +name: Starting a new course + +on: + push: + branches: [ main, staging ] + workflow_dispatch: + +jobs: + # Run cleaning process only if workflow is triggered by not being in the Bookdown template anymore + template-cleanup: + name: Template Cleanup + runs-on: ubuntu-latest + if: github.event.repository.name != 'OTTR_Template' + steps: + - name: checkout repo + uses: actions/checkout@v3 + + - name: Login as jhudsl-robot + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + +##### Delete Template-specific files that aren't needed for new courses + + # Cleanup Template-specific bits + - name: Cleanup + run: | + # Cleanup + rm -rf \ + .github/workflows/report-maker.yml \ + .github/workflows/send-updates.yml \ + .github/workflows/test-send-updates.yml \ + .github/sync.yml \ + .github/test-sync.yml \ + .github/workflows/starting-course.yml \ + .github/ISSUE_TEMPLATE/course-template-problem-report.md \ + .github/ISSUE_TEMPLATE/course-template-feature-request.md \ + resources/code_output \ + resources/screenshots \ + resources/course_screenshots \ + resources/gs_slides \ + resources/image_to_slide_key.tsv \ + resources/images/02-chapter_of_course_files \ + resources/images/03-test_cases_files \ + resources/images/04-figures_files \ + resources/chapt_screen_images \ + Course_Name.rds \ + docs/*.html \ + docs/*.md \ + manuscript/* + + + # Commit modified files + - name: Commit deleted files + id: commit_it + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.email "itcrtrainingnetwork@gmail.com" + git config --global user.name "jhudsl-robot" + git add . + git commit -m "Template cleanup" + pushed_it=true + git push || pushed_it=false + echo "pushed_it=$pushed_it" >> $GITHUB_OUTPUT + + # If main is already protected, then file a PR + - name: Create PR with deleted files + if: steps.commit_it.outputs.pushed_it == 'false' + uses: peter-evans/create-pull-request@v3 + id: pr + with: + commit-message: Delete unnecessary files + signoff: false + branch: auto_copy_rendered_files + delete-branch: true + title: 'Automatic course set up' + body: | + ### Description: + This PR was initiated by the github actions. It helps set up this repository to be ready to write your course. + It deletes some remnant files you don't need for your course but were used when this was a template. + labels: | + automated + reviewers: $GITHUB_ACTOR + token: ${{secrets.GH_PAT}} + +##### Filing issues! + + # Issue for what repository settings need to be set + - name: New Course - Set Repository Settings + uses: peter-evans/create-issue-from-file@v4 + with: + title: New Course - Set Repository Settings + content-filepath: .github/automatic-issues/set-repo-settings.md + labels: automated training issue + + # Issue for what needs to be edited + - name: New Course - Templates to Edit + uses: peter-evans/create-issue-from-file@v4 + with: + title: New Course - Templates to Edit + content-filepath: .github/automatic-issues/templates-to-edit.md + labels: automated training issue + + # Issue for how to enroll repo for updates + - name: New Course - Template Update Enrollment + uses: peter-evans/create-issue-from-file@v4 + with: + title: New Course - Template Update Enrollment + content-filepath: .github/automatic-issues/update-enrollment.md + labels: automated training issue + + # Issue for adding a method of feedback + - name: Reminder - Add a method of user feedback + uses: peter-evans/create-issue-from-file@v4 + with: + title: Reminder - Add user feedback method + content-filepath: .github/automatic-issues/add-feedback-method.md + labels: automated training issue + + - name: Get organization name + id: get_org_name + run: | + org_name=$(dirname ${{github.repository}}) + echo "org_name=$org_name" >> $GITHUB_OUTPUT + echo $org_name + + # Issue for adding the course to the jhudsl library + - name: Reminder - Add to jhudsl library + if: ${{ steps.get_org_name.outputs.org_name == 'jhudsl' }} + uses: peter-evans/create-issue-from-file@v4 + with: + title: Reminder - Add to jhudsl library + content-filepath: .github/automatic-issues/add-to-library.md + labels: automated training issue diff --git a/.github/workflows/test-send-updates.yml b/.github/workflows/test-send-updates.yml index 8c688eb..ffb1afc 100644 --- a/.github/workflows/test-send-updates.yml +++ b/.github/workflows/test-send-updates.yml @@ -22,9 +22,9 @@ jobs: - name: Login as jhudsl-robot 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" - name: Set up test-sync.yml run: | diff --git a/.github/workflows/transfer-rendered-files.yml b/.github/workflows/transfer-rendered-files.yml new file mode 100644 index 0000000..3c3577e --- /dev/null +++ b/.github/workflows/transfer-rendered-files.yml @@ -0,0 +1,112 @@ +# This code was adapted from code written by Josh Shapiro +# for the Childhood Cancer Data Lab, an initiative of Alexs Lemonade Stand Foundation. +# https://github.com/AlexsLemonade/exercise-notebook-answers + +# Adapted for this jhudsl repository by Candace Savonen Apr 2021 + +name: Copy over from main template to _Quizzes repo + +on: + workflow_dispatch: + workflow_run: + workflows: [ "Render all output courses" ] + branches: [ main, staging ] + types: + - completed + +jobs: + + yaml-check: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + # Use the yaml-env-action action. + - name: Load environment from YAML + uses: doughepi/yaml-env-action@v1.0.0 + with: + files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. + outputs: + toggle_coursera: "${{ env.RENDER_COURSERA }}" + toggle_leanpub: "${{ env.RENDER_LEANPUB }}" + + + file-quizzes-pr: + name: File _Quizzes Transfer PR + runs-on: ubuntu-latest + container: + image: jhudsl/ottrpal:main + needs: [yaml-check] + if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes' || needs.yaml-check.outputs.toggle_leanpub == 'yes'}} + + steps: + - name: Run git repo check + id: git_repo_check + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + sudo apt-get install subversion + + # What's the Quizzes repository's name? + QUIZ_REPO=$(echo ${GITHUB_REPOSITORY} | sed "s/_Bookdown/ /g" | sed "s/_Template/ /g" | awk '{print $1"_Quizzes"}') + echo $QUIZ_REPO + + # Get repo check script + svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/scripts/git_repo_check.R git_repo_check.R + + # Run repo check script + results=$(Rscript --vanilla git_repo_check.R --repo "$GITHUB_REPOSITORY" --git_pat "$GH_PAT") + echo $QUIZ_REPO exists: $results + + echo "git_results=$results" >> $GITHUB_OUTPUT + echo "leanpub_repo=$QUIZ_REPO" >> $GITHUB_OUTPUT + + - name: Checkout code from Leanpub repo + if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }} + uses: actions/checkout@v3 + with: + repository: ${{ steps.git_repo_check.outputs.leanpub_repo }} + token: ${{ secrets.GH_PAT }} + + - name: Get files from Bookdown repo + if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }} + shell: bash + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + # Copy over images folder + svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/resources/chapt_screen_images resources/chapt_screen_images + + # Copy over _bookdown.yml + svn export --force https://github.com/${GITHUB_REPOSITORY}.git/branches/${GITHUB_REF#refs/heads/}/_bookdown.yml _bookdown.yml + + - name: Create PR with resources files + if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }} + uses: peter-evans/create-pull-request@v3 + id: cpr + with: + token: ${{ secrets.GH_PAT }} + commit-message: Copy files from Bookdown repository + signoff: false + branch: auto_copy_rendered_files + delete-branch: true + title: 'GHA: Automated transfer of ottrpal-needed files from Bookdown repository' + body: | + ### Description: + This PR was initiated by transfer-rendered.yml in the Bookdown repository. + It copies over the ottrpal-needed folder (for the `bookdown_to_embed_leanpub(render = FALSE)` function + to run properly. + - resources/chapt_screen_images/* + - _bookdown.yml + labels: | + automated + reviewers: $GITHUB_ACTOR + + # Write out PR info + - name: Check outputs + if: ${{ steps.git_repo_check.outputs.git_results == 'TRUE' }} + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3da8ec4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# ignore nonsense files +.DS_Store +.Rhistory +.local +.rstudio +.bash_history +.RData +.httr-oauth +docker/git_token.txt +.Rproj.user +docs/* diff --git a/README.md b/README.md index 97c3d38..75c13ac 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,4 @@ -# OTTR Template for Websites +# Immuno Workflow Course -This is a template for creating websites from Rmd files hosted on GitHub with three helpful automations following a pull request to the repository: spelling check, broken link check, and website rendering. +This course is an introduction to the [immuno workflow](https://github.com/wustl-oncology/analysis-wdls). Automation from ab [OTTR](https://www.ottrproject.org/) template generates [these github pages](https://griffithlab.github.io/Immuno_Workflow_Course) based on the documentation. -Websites will be checked for: - -- Check for spelling errors more intensively than RStudio and allow you to add words to the dictionary -- Check for broken links - you will be warned about broken links - -Website files will also be automatically rendered remotely. This will be triggered when a pull request is merged with a change to files that might influence the contents of your website. - -To learn more about how this site is created see [here](https://bookdown.org/yihui/rmarkdown/rmarkdown-site.html) and [here](https://garrettgman.github.io/rmarkdown/rmarkdown_websites.html). diff --git a/_bookdown.yml b/_bookdown.yml new file mode 100644 index 0000000..f35942c --- /dev/null +++ b/_bookdown.yml @@ -0,0 +1,11 @@ +book_filename: "Immuno Workflow Course" +chapter_name: "Chapter " +repo: https://github.com/jhudsl/OTTR_Template/ +rmd_files: ["index.Rmd", + "terra_walkthrough.Rmd"] +new_session: yes +delete_merged_file: true +language: + ui: + chapter_name: "Chapter" +output_dir: "docs" diff --git a/_output.yml b/_output.yml new file mode 100644 index 0000000..1f06ee0 --- /dev/null +++ b/_output.yml @@ -0,0 +1,15 @@ +bookdown::gitbook: + css: assets/style_ITN.css + includes: + before_body: assets/big-image-itcr.html + after_body: assets/footer.html + highlight: tango + config: + toc: + collapse: section + before: | + + after: | +

This content was published with bookdown by:

+

The Griffith Lab

+

Style adapted from: rstudio4edu-book (CC-BY 2.0)

diff --git a/_site.yml b/_site.yml deleted file mode 100644 index f98a221..0000000 --- a/_site.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Immuno Workflow Course -output_dir: '.' -navbar: - title: Immuno Workflow Course - left: - - text: Home - href: index.html - icon: fa-home - - text: Terra Walkthrough - href: terra_walkthrough.html - -output: - html_document: - theme: cosmo - lib_dir: site_libs - self_contained: no - highlight: textmate - css: styles.css - includes: - in_header: resources/header.html diff --git a/assets/ITN_favicon.ico b/assets/ITN_favicon.ico new file mode 100755 index 0000000..726a500 Binary files /dev/null and b/assets/ITN_favicon.ico differ diff --git a/assets/ITN_logo.png b/assets/ITN_logo.png new file mode 100644 index 0000000..0ade934 Binary files /dev/null and b/assets/ITN_logo.png differ diff --git a/assets/big-image-itcr.html b/assets/big-image-itcr.html new file mode 100644 index 0000000..aea142a --- /dev/null +++ b/assets/big-image-itcr.html @@ -0,0 +1,12 @@ + + + + + + + + + +
+ +
\ No newline at end of file diff --git a/assets/box_images/dictionary.png b/assets/box_images/dictionary.png new file mode 100644 index 0000000..75ddac7 Binary files /dev/null and b/assets/box_images/dictionary.png differ diff --git a/assets/box_images/github.png b/assets/box_images/github.png new file mode 100644 index 0000000..a93acd3 Binary files /dev/null and b/assets/box_images/github.png differ diff --git a/assets/box_images/note.png b/assets/box_images/note.png new file mode 100644 index 0000000..72de3ae Binary files /dev/null and b/assets/box_images/note.png differ diff --git a/assets/box_images/thinking_face.png b/assets/box_images/thinking_face.png new file mode 100644 index 0000000..c2c279a Binary files /dev/null and b/assets/box_images/thinking_face.png differ diff --git a/assets/box_images/warning.png b/assets/box_images/warning.png new file mode 100644 index 0000000..405fb61 Binary files /dev/null and b/assets/box_images/warning.png differ diff --git a/assets/dasl_favicon.ico b/assets/dasl_favicon.ico new file mode 100755 index 0000000..fc3652b Binary files /dev/null and b/assets/dasl_favicon.ico differ diff --git a/assets/footer.html b/assets/footer.html new file mode 100755 index 0000000..0b268e7 --- /dev/null +++ b/assets/footer.html @@ -0,0 +1,8 @@ +
+
+ +
\ No newline at end of file diff --git a/assets/hideOutput.js b/assets/hideOutput.js new file mode 100755 index 0000000..245d55f --- /dev/null +++ b/assets/hideOutput.js @@ -0,0 +1,57 @@ +/*$(document).ready(function() { + + + // Copy Button + $chunks = $('pre.sourceCode > code.sourceCode'); + $chunks.each(function(i, val) { + $(this).prepend("").click(function() { + var $temp = $("