From 8d1384a02e85e8b630faf6925b733a3fab141aaa Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sat, 7 Dec 2024 18:42:29 -0500 Subject: [PATCH 01/11] adding config automation --- config_automation.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 config_automation.yml diff --git a/config_automation.yml b/config_automation.yml new file mode 100644 index 0000000..1c96346 --- /dev/null +++ b/config_automation.yml @@ -0,0 +1,29 @@ +##### Checks run at pull request ##### +# Check quiz formatting +check-quizzes: no +# Check that urls in the content are not broken +url-checker: yes +# Render preview of content with changes (Rmd's and md's are checked) +render-preview: yes +# Spell check Rmds and quizzes +spell-check: yes +# Style any R code +style-code: no +# Test build the docker image if any docker-relevant files have been changed +docker-test: no +# Should URLs be tested periodically? +url-check-periodically: yes + +##### Renderings run upon merge to main branch ##### +# Rendering each platform's content +render-bookdown: yes +render-leanpub: no +render-coursera: no + +## Automate the creation of Book.txt file? TRUE/FALSE? +## This is only relevant if render-leanpub is yes, otherwise it will be ignored +make-book-txt: FALSE + +# What docker image should be used for rendering? +# The default is jhudsl/base_ottr:main +rendering-docker-image: 'jhudsl/base_ottr:main' From d9478fddee2aa50aef6749ef6a4341a7ae46f498 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sat, 7 Dec 2024 18:44:45 -0500 Subject: [PATCH 02/11] adding pull request workflow --- .github/workflows/pull_request.yml | 179 +++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 .github/workflows/pull_request.yml diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..a53a3a7 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,179 @@ + +# Candace Savonen Dec 2021 +# Updated Aug 2024 + +name: Pull Request + +on: + pull_request: + branches: [ main, staging ] + +jobs: + + yaml-check: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + # 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. + + # Delete the branch if this has been run before + - name: Delete branch locally and remotely + run: git push --force origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" + + # Make the branch fresh + - name: Make the branch fresh + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + branch_name='preview-${{ github.event.pull_request.number }}' + echo branch doesnt exist + git checkout -b $branch_name || echo branch exists + git push --force --set-upstream origin $branch_name + shell: bash + + outputs: + public_repository: "${{ steps.public_repository.outputs.public }}" + toggle_spell_check: "${{ env.SPELL_CHECK }}" + toggle_url_check: "${{ env.URL_CHECKER }}" + toggle_render_preview: "${{ env.RENDER_PREVIEW }}" + rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" + +########################## Make the error reports ############################## + spell-check: + name: Check spelling + needs: yaml-check + if: ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}} + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main + with: + check_type: spelling + error_min: 3 + gh_pat: secrets.GH_PAT + + url-check: + name: Check URLs + needs: yaml-check + if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}} + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main + with: + check_type: urls + error_min: 0 + gh_pat: secrets.GH_PAT + + render-preview: + name: Render preview + needs: yaml-check + runs-on: ubuntu-latest + container: + image: ${{needs.yaml-check.outputs.rendering_docker_image}} + if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}} + + steps: + - name: Checkout files + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Set up git checkout + - name: Set up git checkout + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + 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 + + # 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()" + + # 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' + run: | + echo site status ${{steps.site.outcome}} + exit 1 + + - name: Website preview for download + run: zip website-preview.zip docs/* -r + + # Commit the website files + - name: Commit rendered website files + id: commit + run: | + branch_name='preview-${{ github.event.pull_request.number }}' + 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 --rebase --set-upstream origin $branch_name --allow-unrelated-histories --strategy-option=ours + git push --force || echo "No changes to commit" + shell: bash + + - name: Find Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: latest commit + + - 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 }}/docs/index.html") + docs_link=$(echo "https://github.com/$GITHUB_REPOSITORY/raw/preview-${{ github.event.pull_request.number }}/website-preview.zip") + echo "zip_link=$docs_link" >> $GITHUB_OUTPUT + echo "website_link=$website_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@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + :eyes: Quick [preview of website here](${{ steps.build-components.outputs.website_link }}) \* + :microscope: Comprehensive [download of the website here](${{ steps.build-components.outputs.zip_link }}) + + \* note not all html features will be properly displayed in the "quick preview" but it will give you a rough idea. + + _Updated at ${{ steps.build-components.outputs.time }} with changes from the latest commit ${{ steps.build-components.outputs.commit_id }}_ + edit-mode: replace + + - name: No comment if no changes + if: steps.commit.outputs.changes == 'false' + uses: peter-evans/create-or-update-comment@v3 + 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 From 353cd316ce4e9db5deeab1022528ea6b89d05e93 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 8 Dec 2024 16:34:07 -0500 Subject: [PATCH 03/11] adding index file --- template.Rmd => index.Rmd | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename template.Rmd => index.Rmd (100%) diff --git a/template.Rmd b/index.Rmd similarity index 100% rename from template.Rmd rename to index.Rmd From d0851555a8b1fd08eff996c9f20a810b68761e80 Mon Sep 17 00:00:00 2001 From: carriewright11 Date: Sun, 8 Dec 2024 16:43:58 -0500 Subject: [PATCH 04/11] add delete preview workflow --- .github/workflows/delete-preview.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/delete-preview.yml diff --git a/.github/workflows/delete-preview.yml b/.github/workflows/delete-preview.yml new file mode 100644 index 0000000..faa83cc --- /dev/null +++ b/.github/workflows/delete-preview.yml @@ -0,0 +1,27 @@ +# Candace Savonen Apr 2021 + +name: Delete Preview + +on: + pull_request: + types: [closed] + +jobs: + delete-preview: + 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 + shell: bash + + # Check out current repository + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Delete the branch! + - name: Delete branch locally and remotely + run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" From 773b46c55a5431213c2f8d1a38bdf4914d844624 Mon Sep 17 00:00:00 2001 From: Kate Isaac <41767733+kweav@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:43:28 -0500 Subject: [PATCH 05/11] will this fix render preview maybe --- _site.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 _site.yml diff --git a/_site.yml b/_site.yml new file mode 100644 index 0000000..902cf39 --- /dev/null +++ b/_site.yml @@ -0,0 +1,22 @@ +name: ITN Software Cheatsheets +output_dir: '../docs' +navbar: + title: ITN Software (OTTR, metricminer) Cheatsheets + left: + - text: "" + href: index.html + icon: fa-home + - text: OTTR Website Setup + href: website_setup.html + + + +output: + html_document: + theme: cosmo + lib_dir: site_libs + self_contained: no + highlight: textmate + css: styles.css + includes: + in_header: resources/header.html From 64d0db13665616af8e4731f312897d7289d556ee Mon Sep 17 00:00:00 2001 From: Kate Isaac <41767733+kweav@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:05:15 -0500 Subject: [PATCH 06/11] pointing to wrong output --- _site.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_site.yml b/_site.yml index 902cf39..447c386 100644 --- a/_site.yml +++ b/_site.yml @@ -1,5 +1,5 @@ name: ITN Software Cheatsheets -output_dir: '../docs' +output_dir: 'docs' navbar: title: ITN Software (OTTR, metricminer) Cheatsheets left: From 8c553152b5a2382a77999f23b6dc8170a1de3ba7 Mon Sep 17 00:00:00 2001 From: Kate Isaac <41767733+kweav@users.noreply.github.com> Date: Tue, 17 Dec 2024 16:17:48 -0500 Subject: [PATCH 07/11] revert --- _site.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 _site.yml diff --git a/_site.yml b/_site.yml deleted file mode 100644 index 447c386..0000000 --- a/_site.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: ITN Software Cheatsheets -output_dir: 'docs' -navbar: - title: ITN Software (OTTR, metricminer) Cheatsheets - left: - - text: "" - href: index.html - icon: fa-home - - text: OTTR Website Setup - href: website_setup.html - - - -output: - html_document: - theme: cosmo - lib_dir: site_libs - self_contained: no - highlight: textmate - css: styles.css - includes: - in_header: resources/header.html From bfb48ca2297f7047bf549606666b697917db8ee3 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Thu, 19 Dec 2024 13:34:21 -0500 Subject: [PATCH 08/11] Add site yml file --- _site.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 _site.yml diff --git a/_site.yml b/_site.yml new file mode 100644 index 0000000..1ce7793 --- /dev/null +++ b/_site.yml @@ -0,0 +1,21 @@ +name: OTTR Cheatsheets +output_dir: 'docs' +navbar: + title: cheatsheets + left: + - text: "" + href: index.html + icon: fa-home + - text: Website Setup + href: website_setup.html + + +output: + html_document: + theme: cosmo + lib_dir: site_libs + self_contained: no + highlight: textmate + css: styles.css + includes: + in_header: resources/header.html From 3b2d7baee51399ec7ff7497b7237429f98c78fe8 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Thu, 19 Dec 2024 13:36:18 -0500 Subject: [PATCH 09/11] add header.html --- resources/header.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 resources/header.html diff --git a/resources/header.html b/resources/header.html new file mode 100644 index 0000000..a4b1f27 --- /dev/null +++ b/resources/header.html @@ -0,0 +1,2 @@ + + From f6d3ddb30b299deb3da657d42fee20a3e5008df4 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Thu, 19 Dec 2024 13:39:54 -0500 Subject: [PATCH 10/11] Add dictionary.txt --- .DS_Store | Bin 0 -> 6148 bytes resources/dictionary.txt | 27 +++++++++++++++++++++++++++ resources/ignore-urls.txt | 1 + 3 files changed, 28 insertions(+) create mode 100644 .DS_Store create mode 100644 resources/dictionary.txt create mode 100644 resources/ignore-urls.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4e7b2e64be6bbfd78a4757ad5bd0bac3ac3070e9 GIT binary patch literal 6148 zcmeHKI|>3p3{BKRvDwmcuHX#@(Gz$9@zV(liv3oe%cJ@7L6p@-u#p!?-b^-chk3YQea<$Mmdv4ydL1q*P$2%@^lARpnyg&D<-zSVa0Sg>ypZUAvwr!8^ zNz76KDnJFO02QDDUn^j}7dD;-GExC5Km{HO*!Q8p4QpZ-=${S*9|3?Pq}{OgSprxr z0j!B#ATlrwDln*;BZdYY`I2=tu?q~kXbvBmCu>e9>ZjxV#mhx&AR`r^0#>1%9o-9r}b7y#N3J literal 0 HcmV?d00001 diff --git a/resources/dictionary.txt b/resources/dictionary.txt new file mode 100644 index 0000000..c3bf9f5 --- /dev/null +++ b/resources/dictionary.txt @@ -0,0 +1,27 @@ +cheatsheet +css +custimization +cwrigh +Dockerfile +Dockerhub +favicon +GH +Github +GitHub +HTTPS +ITN +ITCR +lightblue +lightgreen +OTTR +Rmd +repo +subdir +th +tibble +www +automations +Bootstap +glyphicons +repo +RStudio diff --git a/resources/ignore-urls.txt b/resources/ignore-urls.txt new file mode 100644 index 0000000..d762bdd --- /dev/null +++ b/resources/ignore-urls.txt @@ -0,0 +1 @@ +https://username.github.io/repository_name/ From 8cb8172368db9dbfeee7d3100f35a5e0380a6983 Mon Sep 17 00:00:00 2001 From: Candace Savonen Date: Thu, 19 Dec 2024 13:43:44 -0500 Subject: [PATCH 11/11] Fix spelling errors --- index.Rmd | 4 ++-- resources/dictionary.txt | 1 + website_setup.Rmd | 18 +++++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/index.Rmd b/index.Rmd index c16a41a..6099041 100644 --- a/index.Rmd +++ b/index.Rmd @@ -14,9 +14,9 @@ knitr::opts_chunk$set(echo = TRUE) ## R Markdown - adfasfd + step - afdafsd + step [this is a link](https://www.itcrtraining.org/) diff --git a/resources/dictionary.txt b/resources/dictionary.txt index c3bf9f5..331c88b 100644 --- a/resources/dictionary.txt +++ b/resources/dictionary.txt @@ -1,3 +1,4 @@ +github cheatsheet css custimization diff --git a/website_setup.Rmd b/website_setup.Rmd index 437a175..c66b045 100644 --- a/website_setup.Rmd +++ b/website_setup.Rmd @@ -44,7 +44,7 @@ A. [Create a personal access token](https://docs.github.com/en/authentication/ke Select **Generate new token (classic)** personal access token icon - Underneath **Select Scopes**, *check both* **repo** and **workflow** + Underneath **Select Scopes**, *check both* **repo** and **workflow** Click: @@ -54,7 +54,7 @@ B. [Save the copied personal access token as a repository secret](https://docs.g In your OTTR repository, go to **Settings** in the top navigation tabs settings icon - Go to **Secrets and variables** in the side navigation secrets icon + Go to **Secrets and variables** in the side navigation secrets icon Click on **Actions** @@ -72,14 +72,14 @@ B. [Save the copied personal access token as a repository secret](https://docs.g Go to **Pages** in the side navigation pages icon - In the **Build and deployment section** + In the **Build and deployment section** + + 1. Under **Source**, select **Deploy from a branch** + 2. Under **Branch**, pick **main** and choose **/docs**, and click **Save** + + at the button of the page, check **Enforce HTTPS** + - 1. Under **Source**, select **Deply from a branch** - 2. Under **Branch**, pick **main** and choose **/docs**, and click **Save** - - at the botton of the page, check **Enforce HTTPS** - - ## Enroll your OTTR repository for template updates Refer to our Template Updates Cheatsheet