diff --git a/.github/workflows/check-url-2.yml b/.github/workflows/check-url-2.yml new file mode 100644 index 0000000..1ff5987 --- /dev/null +++ b/.github/workflows/check-url-2.yml @@ -0,0 +1,121 @@ +name: Periodic URL Check 2 + + +on: + workflow_dispatch: + schedule: + - cron: '0 0 1 * *' + +jobs: + set-up: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # 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_url_check_periodically: "${{ env.URL_CHECK_PERIODICALLY }}" + + url-check: + name: Check URLs + needs: set-up + if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'true'}} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Delete the branch if this has been run before + - name: Delete branch locally and remotely + run: git push origin --delete preview-spell-error || 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' + + echo branch doesnt exist + git checkout -b preview-spell-error || echo branch exists + git push --set-upstream origin preview-spell-error || echo echo branch exists remotely + shell: bash + + - name: Run the check + uses: ottrproject/ottr-reports@main + id: check_results + continue-on-error: true + with: + check_spelling: false + spelling_error_min: 1 + check_urls: true + url_error_min: 1 + check_quiz_form: false + quiz_error_min: 1 + sort_dictionary: false + + - name: Declare file path and time + id: check-report + run: | + error_num=$(cat check_reports/url_checks.tsv | wc -l) + error_num="$((error_num-1))" + echo "error_num=$error_num" >> $GITHUB_OUTPUT + echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/preview-spell-error/check_reports/url_checks.tsv" >> $GITHUB_OUTPUT + shell: bash + + - name: Stop if failure + if: steps.check_results.outcome == 'failure' + run: exit 1 + + - name: Print out error variables + run: | + echo ${{ steps.check-report.outputs.error_url }} + echo ${{ steps.check-report.outputs.error_num }} + + # Commit file + - name: Commit tocless bookdown files + if: ${{ steps.check-report.outputs.error_num >= 1 }} + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + git add --force check_reports/url_checks.tsv + git commit -m 'Add spell check file' || echo "No changes to commit" + git push --set-upstream origin preview-spell-error || echo echo branch exists remotely + + - name: Find issues + id: find-issue + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + echo "$GITHUB_REPOSITORY" + curl -o find_issue.R https://raw.githubusercontent.com/ottrproject/ottr-reports/main/scripts/find_issue.R + issue_exists=$(Rscript --vanilla find_issue.R --repo $GITHUB_REPOSITORY --git_pat $GH_PAT) + echo URL issue exists: $issue_exists + echo "issue_existence=$issue_exists" >> $GITHUB_OUTPUT + + - name: If too many URL errors, then make an issue + if: ${{ steps.check-report.outputs.error_num >= 1 && steps.find-issue.outputs.issue_existence == 0}} + uses: JasonEtco/create-an-issue@v2 + with: + filename: .github/ISSUE_TEMPLATE/url-error.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILE_URL: ${{ steps.check-report.outputs.error_url }} + ERROR_NUM: ${{ steps.check-report.outputs.error_num }} + + - name: If no URL errors than delete the branch we made + if: ${{ steps.check-report.outputs.error_num < 1 }} + run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" + git push origin --delete preview-spell-error || echo "No branch to delete" diff --git a/.github/workflows/check-url.yml b/.github/workflows/check-url.yml new file mode 100644 index 0000000..6cfef1a --- /dev/null +++ b/.github/workflows/check-url.yml @@ -0,0 +1,122 @@ +name: Periodic URL Check + +on: + workflow_dispatch: + schedule: + - cron: '0 0 1 * *' + +jobs: + set-up: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # 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_url_check_periodically: "${{ env.URL_CHECK_PERIODICALLY }}" + + url-check: + name: Check URLs + needs: set-up + if: ${{needs.set-up.outputs.toggle_url_check_periodically == 'true'}} + runs-on: ubuntu-latest + container: + image: jhudsl/base_ottr:main + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # Delete the branch if this has been run before + - name: Delete branch locally and remotely + run: git push origin --delete preview-spell-error || 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' + + echo branch doesnt exist + git checkout -b preview-spell-error || echo branch exists + git push --set-upstream origin preview-spell-error || echo echo branch exists remotely + shell: bash + + - name: Run the check + uses: ottrproject/ottr-reports@main + id: check_results + continue-on-error: true + with: + check_spelling: false + spelling_error_min: 1 + check_urls: true + url_error_min: 1 + check_quiz_form: false + quiz_error_min: 1 + sort_dictionary: false + + - name: Declare file path and time + id: check-report + run: | + error_num=$(cat check_reports/url_checks.tsv | wc -l) + error_num="$((error_num-1))" + echo "error_num=$error_num" >> $GITHUB_OUTPUT + echo "error_url=https://github.com/${GITHUB_REPOSITORY}/blob/preview-spell-error/check_reports/url_checks.tsv" >> $GITHUB_OUTPUT + shell: bash + + - name: Stop if failure + if: steps.check_results.outcome == 'failure' + run: exit 1 + + - name: Print out error variables + run: | + echo ${{ steps.check-report.outputs.error_url }} + echo ${{ steps.check-report.outputs.error_num }} + + # Commit file + - name: Commit tocless bookdown files + if: ${{ steps.check-report.outputs.error_num >= 1 }} + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + git add --force check_reports/url_checks.tsv + git commit -m 'Add spell check file' || echo "No changes to commit" + git push --set-upstream origin preview-spell-error || echo echo branch exists remotely + + - name: Find issues + id: find-issue + env: + GH_PAT: ${{ secrets.GH_PAT }} + run: | + echo "$GITHUB_REPOSITORY" + curl -o find_issue.R https://raw.githubusercontent.com/ottrproject/ottr-reports/main/scripts/find_issue.R + issue_exists=$(Rscript --vanilla find_issue.R --repo $GITHUB_REPOSITORY --git_pat $GH_PAT) + echo URL issue exists: $issue_exists + echo "issue_existence=$issue_exists" >> $GITHUB_OUTPUT + + - name: If too many URL errors, then make an issue + if: ${{ steps.check-report.outputs.error_num >= 1 && steps.find-issue.outputs.issue_existence == 0}} + uses: JasonEtco/create-an-issue@v2 + with: + filename: .github/ISSUE_TEMPLATE/url-error.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILE_URL: ${{ steps.check-report.outputs.error_url }} + ERROR_NUM: ${{ steps.check-report.outputs.error_num }} + + - name: If no URL errors than delete the branch we made + if: ${{ steps.check-report.outputs.error_num < 1 }} + run: | + git config --system --add safe.directory "$GITHUB_WORKSPACE" + git push origin --delete preview-spell-error || echo "No branch to delete" diff --git a/.github/workflows/delete-preview.yml b/.github/workflows/delete-preview.yml index afd658a..faa83cc 100644 --- a/.github/workflows/delete-preview.yml +++ b/.github/workflows/delete-preview.yml @@ -18,7 +18,7 @@ jobs: # Check out current repository - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9316682..9b3ece7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,5 @@ # Candace Savonen 2021 -# Updated Jan 2023 +# Updated May 2025 name: Pull Request @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -32,187 +32,121 @@ jobs: - name: Make the branch fresh 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 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 --set-upstream origin $branch_name + git push --set-upstream origin $branch_name || echo branch exists remotely shell: bash + outputs: + toggle_website: "${{ env.RENDER_WEBSITE }}" toggle_spell_check: "${{ env.SPELL_CHECK }}" + spell_error_min: "${{ env.SPELL_ERROR_MIN }}" toggle_style_code: "${{ env.STYLE_CODE }}" toggle_url_check: "${{ env.URL_CHECKER }}" + url_error_min: "${{ env.URL_ERROR_MIN }}" toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" + quiz_error_min: "${{ env.QUIZ_ERROR_MIN }}" + toggle_md_linter: "${{ env.MARKDOWN_LINTER }}" + toggle_readability: "${{ env.READABILITY_REPORT }}" toggle_render_preview: "${{ env.RENDER_PREVIEW }}" + toggle_dictionary_sort: "${{ env.DICTIONARY_SORT }}" 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 + ottr-reports: + name: Run Reports 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 - - 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 + if: ${{needs.yaml-check.outputs.toggle_spell_check == 'true' || needs.yaml-check.outputs.toggle_url_check == 'true' || needs.yaml-check.outputs.toggle_quiz_check == 'true'}} + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Checkout Actions Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run Reports + id: run-reports + uses: ottrproject/ottr-reports@main + with: + check_spelling: ${{needs.yaml-check.outputs.toggle_spell_check}} + spelling_error_min: ${{needs.yaml-check.outputs.spell_error_min}} + check_urls: ${{needs.yaml-check.outputs.toggle_url_check}} + url_error_min: ${{needs.yaml-check.outputs.url_error_min}} + check_quiz_form: ${{needs.yaml-check.outputs.toggle_quiz_check}} + quiz_error_min: ${{needs.yaml-check.outputs.quiz_error_min}} + sort_dictionary: ${{needs.yaml-check.outputs.toggle_dictionary_sort}} ############################# Style the code ################################### style-code: name: Style code needs: yaml-check runs-on: ubuntu-latest - if: ${{needs.yaml-check.outputs.toggle_style_code == 'yes'}} + if: ${{needs.yaml-check.outputs.toggle_style_code == 'true'}} container: image: jhudsl/base_ottr:main steps: - name: Checkout files - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Run styler - run: Rscript -e "styler::style_file(list.files(pattern = 'Rmd$', recursive = TRUE, full.names = TRUE));warnings()" + run: Rscript -e "styler::style_file(list.files(pattern = '(R|q)md$', recursive = FALSE, 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 add \*md + git commit -m 'Style *mds' || echo "No changes to commit" git push origin || echo "No changes to commit" -############################# Render Preview ################################### +############################# Readability Report ################################### - render-preview: - name: Render preview + readability-report: + name: Readability report 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'}} + if: ${{needs.yaml-check.outputs.toggle_readability == 'true'}} steps: - - name: Checkout files - uses: actions/checkout@v3 + - name: Checkout repo + 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.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 - - # Run bookdown rendering - - name: Run bookdown render - id: bookdown - run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')" - - # 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.bookdown.outcome != 'success' || steps.tocless.outcome != 'success' - run: | - echo Bookdown status ${{steps.bookdown.outcome}} - echo Toc-less status ${{steps.tocless.outcome}} - exit 1 - - # 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 -- 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 - git push --force || echo "No changes to commit" - shell: bash - - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc + - name: Readability report + uses: Rebilly/lexi@v2 with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: latest commit + github-token: ${{ secrets.GH_PAT }} + glob: '**/*.md' - - 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") - 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@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 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: Comment if no changes - if: steps.commit.outputs.changes == 'false' - uses: peter-evans/create-or-update-comment@v2 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - The latest commit did not produce rendering changes. +############################# Render Preview ################################### + render-preview: + name: Render preview + needs: yaml-check + runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_render_preview == 'true'}} + permissions: + pull-requests: write + contents: write - _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Run render + uses: ottrproject/ottr-preview@main + with: + toggle_website: ${{needs.yaml-check.outputs.toggle_website}} + docker_image: ${{needs.yaml-check.outputs.rendering_docker_image}} diff --git a/.github/workflows/render-all.yml b/.github/workflows/render-all.yml index 083817a..e404e09 100644 --- a/.github/workflows/render-all.yml +++ b/.github/workflows/render-all.yml @@ -1,5 +1,5 @@ - -# Candace Savonen Apr 2021 +# Candace Savonen 2021 +# Updated April 2025 name: Render all output courses @@ -8,8 +8,10 @@ on: push: branches: [ main, staging ] paths: - - '**.Rmd' + - '*.qmd' + - '*.Rmd' - assets/* + - quizzes/* jobs: @@ -18,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Use the yaml-env-action action. - name: Load environment from YAML @@ -26,124 +28,106 @@ jobs: with: files: config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence. outputs: - toggle_bookdown: "${{ env.RENDER_BOOKDOWN }}" + toggle_website: "${{ env.RENDER_WEBSITE }}" 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 + render-course: + name: Render course preview 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 + uses: actions/checkout@v4 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" + - name: Run render + id: render + uses: ottrproject/ottr-preview@main + with: + toggle_website: ${{needs.yaml-check.outputs.toggle_website}} + preview: false + token: ${{ secrets.GH_PAT }} + docker_image: ${{needs.yaml-check.outputs.rendering_docker_image}} render-tocless: name: Render TOC-less version for Leanpub or Coursera - needs: [yaml-check] + needs: [yaml-check, render-course] 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'}} + if: ${{needs.yaml-check.outputs.toggle_coursera == 'true' || needs.yaml-check.outputs.toggle_leanpub == 'true'}} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_PAT }} - - name: Login as jhudsl-robot + - name: Login as github-actions bot 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 config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git pull --rebase --allow-unrelated-histories --strategy-option=ours # 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 + - name: Run TOC-less version of render -- Rmd version + if: ${{needs.yaml-check.outputs.toggle_website == 'rmd' }} + id: tocless_rmd run: Rscript -e "ottrpal::render_without_toc()" + - name: Run TOC-less version of render -- quarto version + id: tocless_quarto + if: ${{needs.yaml-check.outputs.toggle_website == 'quarto' }} + run: | + Rscript -e "quarto::quarto_render('.', metadata = list(sidebar = F, toc = F), + quarto_args = c('--output-dir', 'docs/no_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" + git status docs/no_toc* + git push --force -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'}} + image: jhudsl/base_ottr:dev + if: ${{needs.yaml-check.outputs.toggle_leanpub == 'true'}} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_PAT }} - - name: Login as jhudsl-robot + - name: Login as github actions bot 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 config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git pull --rebase --allow-unrelated-histories --strategy-option=ours + ls docs/no_toc # Create screenshots - name: Run the screenshot creation @@ -152,10 +136,12 @@ jobs: 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) + chapt_urls=$(Rscript -e " \ + Sys.setenv(CHROMOTE_CHROME = '/usr/bin/vivaldi'); \ + ottrpal::make_screenshots( \ + token = '${{ secrets.GH_PAT }}', \ + repo = '$GITHUB_REPOSITORY' )" \ + ) # We want a fresh run of the renders each time - name: Delete manuscript/ @@ -163,41 +149,38 @@ jobs: 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' + - name: Run ottrpal::bookdown_to_embed_leanpub -- No Quiz + if: ${{ needs.yaml-check.outputs.toggle_quiz_check != 'true'}} run: | - Rscript -e "ottrpal::bookdown_to_embed_leanpub( + Rscript -e "ottrpal::website_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}}'), \ + make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt == 'true'}}'), \ quiz_dir = NULL)" - - name: Run ottrpal::bookdown_to_embed_leanpub - if: needs.yaml-check.outputs.toggle_quiz_check == 'yes' + - name: Run ottrpal::bookdown_to_embed_leanpub -- with Quiz + if: ${{ needs.yaml-check.outputs.toggle_quiz_check == 'true'}} run: | - Rscript -e "ottrpal::bookdown_to_embed_leanpub( + Rscript -e "ottrpal::website_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}}'))" + make_book_txt = as.logical('${{needs.yaml-check.outputs.make_book_txt == 'true'}}'))" # 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 add --force manuscript/* || "No files to add" + git add --force resources/* || "No files to add" + git add --force docs/* || "No files to add" git commit -m 'Render Leanpub' || echo "No changes to commit" - git pull --allow-unrelated-histories --strategy-option=ours + git status docs/* + git pull --rebase --allow-unrelated-histories --strategy-option=ours --autostash git push --force --set-upstream origin main || echo "No changes to push" render-coursera: @@ -206,37 +189,41 @@ jobs: runs-on: ubuntu-latest container: image: ${{needs.yaml-check.outputs.rendering_docker_image}} - if: ${{needs.yaml-check.outputs.toggle_coursera == 'yes'}} + if: ${{needs.yaml-check.outputs.toggle_coursera == 'true'}} steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GH_PAT }} - - name: Login as jhudsl-robot + - name: Login as github action 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 config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git remote set-url origin https://${GH_PAT}@github.com/${GITHUB_REPOSITORY} + git fetch origin + git pull --rebase --allow-unrelated-histories --strategy-option=ours # 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' + if: needs.yaml-check.outputs.toggle_leanpub == 'true' && needs.yaml-check.outputs.toggle_quiz_check == 'true' id: coursera run: Rscript -e "ottrpal::convert_coursera_quizzes()" - # Commit the rendered bookdown files + # Commit the rendered files + # Only commit coursera quizzes if the directory is present - 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/* + if [ -d 'coursera_quizzes' ]; then + git add --force coursera_quizzes/* + fi 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" + git status + git push --force -u origin main || echo "No changes to push" diff --git a/assets/box_images/under_construction.png b/assets/box_images/under_construction.png new file mode 100644 index 0000000..a67bd5c Binary files /dev/null and b/assets/box_images/under_construction.png differ diff --git a/assets/style.css b/assets/style.css index 21ed0c6..587dd94 100755 --- a/assets/style.css +++ b/assets/style.css @@ -1,7 +1,9 @@ +/* variables are set in style_config_default.css */ + @import url('https://fonts.googleapis.com/css?family=Abril+Fatface|Karla:400,400i,700,700i|Lora:400,400i,700,700i&display=swap'); p.caption { - color: #777; + color: var(--caption-color); margin-top: 10px; } p code { @@ -43,7 +45,8 @@ pre code { /* ------------Links------------------ */ .book .book-body .page-wrapper .page-inner section.normal a { - color: #68ace5; + color: var(--link-color); + text-decoration: underline; } @@ -71,14 +74,14 @@ h1, h2, h3, h4 { .title { font-family: 'Lora'; font-size: 4em !important; - color: #012d72; + color: var(--accent-color); margin-top: 0.275em !important; margin-bottom: 0.35em !important; } .subtitle { font-family: 'Lora'; - color: #0b8d96; + color: var(--link-color); } @@ -99,7 +102,7 @@ h1, h2, h3, h4 { */ .section.level1 > p:first-of-type:first-letter { /*drop cap for first p beneath level 1 headers only within class .section*/ - color: #012d72; + color: var(--accent-color); float: left; font-family: 'Abril Fatface', serif; font-size: 7em; @@ -131,14 +134,14 @@ h1, h2, h3, h4 { .book .book-summary { - background: white; + background: var(--background-color); border-right: none; } /*---color of links in TOC----*/ .book .book-summary a { -color: #012d72 +color: var(--accent-color) } .summary{ @@ -152,17 +155,17 @@ color: #012d72 padding-bottom: 8px; padding-left: 15px; padding-right: 15px; - color: #012d72; + color: var(--accent-color); } .summary a:hover { - color: #68ace5 !important; + color: var(--highlight-color) !important; } .book .book-summary ul.summary li.active>a { /*active TOC links*/ - color: #68ace5 !important; + color: var(--link-color) !important; border-left: solid 4px; - border-color: #68ace5; + border-color: var(--highlight-color); padding-left: 11px !important; } @@ -250,7 +253,7 @@ li.appendix span, li.part span { /* for TOC part names */ /* Sidebar formating --------------------------------------------*/ /* from r-pkgs.org*/ -div.notice, div.warning, div.github, div.dictionary, div.reflection { +div.notice, div.warning, div.github, div.dictionary, div.reflection, div.wip { padding: 1em; margin: 1em 0; padding-left: 100px; @@ -259,11 +262,11 @@ div.notice, div.warning, div.github, div.dictionary, div.reflection { } div.notice{ - border: 4px #68ace5; + border: 4px var(--highlight-color); border-style: solid; background-size: 70px; background-position: 15px center; - background-color: #e8ebee; + background-color: var(--callout-background-color); background-image: url("../assets/box_images/note.png"); } @@ -273,7 +276,7 @@ div.warning{ border-style: solid; background-size: 70px; background-position: 15px center; - background-color: #e8ebee; + background-color: var(--callout-background-color); background-image: url("../assets/box_images/warning.png"); } @@ -282,28 +285,36 @@ div.github{ border-style: solid; background-size: 70px; background-position: 15px center; - background-color: #e8ebee; + background-color: var(--callout-background-color); background-image: url("../assets/box_images/github.png"); } div.dictionary{ - border: 4px #68ace5; + border: 4px var(--highlight-color); border-style: solid; background-size: 70px; background-position: 15px center; - background-color: #e8ebee; + background-color: var(--callout-background-color); background-image: url("../assets/box_images/dictionary.png"); } div.reflection{ - border: 4px #68ace5; + border: 4px var(--highlight-color); border-style: solid; background-size: 90px; background-position: 15px center; - background-color: #e8ebee; + background-color: var(--callout-background-color); background-image: url("../assets/box_images/thinking_face.png"); } +div.wip{ + border: 4px #000000; + border-style: solid; + background-size: 70px; + background-position: 15px center; + background-color: #f4d03f; + background-image: url("../assets/box_images/under_construction.png"); +} /* .book .book-body .page-wrapper .page-inner section.normal is needed to override the styles produced by gitbook, which are ridiculously @@ -426,5 +437,5 @@ a.anchor:hover { .footer { font-family: "Lora", serif; font-size: .85em; - color: #193a5c; + color: var(--accent-color); } diff --git a/assets/style_config_default.css b/assets/style_config_default.css new file mode 100644 index 0000000..1c7f4bd --- /dev/null +++ b/assets/style_config_default.css @@ -0,0 +1,8 @@ +:root { + --link-color: #0b5b9d; + --accent-color: #012d72; /* book title, first letter of chapter, toc text */ + --highlight-color: #68ace5; /* toc highlight, callout box borders */ + --caption-color: #595959; + --background-color: white; + --callout-background-color: #e8ebee; + } \ No newline at end of file diff --git a/config_automation.yml b/config_automation.yml index 4fc09ca..3c7941e 100644 --- a/config_automation.yml +++ b/config_automation.yml @@ -1,27 +1,39 @@ +### Render preview of content with changes (Rmd's and md's are checked) +render-preview: true + ##### Checks run at pull request ##### # Check quiz formatting -check-quizzes: yes +check-quizzes: false +quiz_error_min: 0 # 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 +url-checker: true +url_error_min: 0 # Spell check Rmds and quizzes -spell-check: yes +spell-check: true +spell_error_min: 0 + +#### Other options # Style any R code -style-code: yes +style-code: true +# Would you like your markdown files to be checked for formatting +markdown-linter: true +# Would you like a readability report on your markdowns? +readability-report: true # Test build the docker image if any docker-relevant files have been changed -docker-test: no +docker-test: false +# Should URLs be tested periodically? +url-check-periodically: true ##### Renderings run upon merge to main branch ##### # Rendering each platform's content -render-bookdown: yes -render-leanpub: yes -render-coursera: no +render-website: rmd +render-leanpub: true +render-coursera: true -## Automate the creation of Book.txt file? TRUE/FALSE? +## Automate the creation of Book.txt file? yes/no ## This is only relevant if render-leanpub is yes, otherwise it will be ignored -make-book-txt: FALSE +make-book-txt: true # What docker image should be used for rendering? # The default is jhudsl/base_ottr:main diff --git a/resources/exclude_files.txt b/resources/exclude_files.txt new file mode 100644 index 0000000..5525a40 --- /dev/null +++ b/resources/exclude_files.txt @@ -0,0 +1,8 @@ +About.Rmd +docs/* +style-sets/* +manuscript/* +CONTRIBUTING.md +LICENSE.md +code_of_conduct.md +README.md