From 0151cf55a18d9e7a3781b2c321c4aaec22455461 Mon Sep 17 00:00:00 2001 From: jhudsl-robot Date: Fri, 6 Jun 2025 21:06:31 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=84=20Synced=20local=20'.github/wo?= =?UTF-8?q?rkflows/'=20with=20remote=20'.github/workflows/'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release-renderActionTry2 --- .github/workflows/build-collection.yml | 97 ---------- .github/workflows/check-url.yml | 117 ++++++++++++ .github/workflows/delete-preview.yml | 2 +- .github/workflows/docker-test.yml | 90 ++++++++++ .github/workflows/pull_request.yml | 237 ++++++++++--------------- .github/workflows/render-all.yml | 53 ++++++ .github/workflows/render-site.yml | 107 ----------- 7 files changed, 351 insertions(+), 352 deletions(-) delete mode 100644 .github/workflows/build-collection.yml create mode 100644 .github/workflows/check-url.yml create mode 100644 .github/workflows/docker-test.yml create mode 100644 .github/workflows/render-all.yml delete mode 100644 .github/workflows/render-site.yml diff --git a/.github/workflows/build-collection.yml b/.github/workflows/build-collection.yml deleted file mode 100644 index c78b33eb..00000000 --- a/.github/workflows/build-collection.yml +++ /dev/null @@ -1,97 +0,0 @@ - -name: Build Collection - -on: - workflow_call: - inputs: - render-type: - required: true - type: string - repository: - type: string - required: true - image-name: - type: string - required: true - secrets: - gh_pat: - required: true - -jobs: - build-repo-collection: - name: Gather Repositories - runs-on: ubuntu-latest - container: - image: ${{ inputs.image-name }} - - steps: - - name: Checkout files - uses: actions/checkout@v4 - with: - fetch-depth: 0 - token: ${{ secrets.gh_pat }} - - - name: Configure git - run: | - git config --system --add safe.directory "$GITHUB_WORKSPACE" - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - shell: bash - - - name: Merge if rendering preview - if: ${{ inputs.render-type == 'preview' }} - run: | - 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 - - - name: Checkout if main - if: ${{ inputs.render-type == 'main' }} - run: | - git fetch --all - git checkout main - shell: bash - - - name: Query API and make repo collection - id: anvil_repos - env: - GH_PAT: ${{ secrets.gh_pat }} - run: | - sudo apt-get install libcurl4-openssl-dev - - # Need a clean render of the collection every time - rm -f resources/collection.tsv - rm -f index.html - - # Run repo check script - Rscript --vanilla "scripts/query_collection.R" --git_pat "$GH_PAT" - - - name: Archive collection - uses: actions/upload-artifact@v4.6.2 - with: - name: collection - path: resources/collection.tsv - - # Commit the rendered bookdown files - - name: Commit collection .tsv to main - if: ${{ inputs.render-type == 'main' }} - env: - GH_PAT: ${{ secrets.gh_pat }} - run: | - git add --force resources/collection.tsv - git commit -m 'Add collection file' || echo "No changes to commit" - git fetch - git merge -s recursive --strategy-option=ours origin/main --allow-unrelated-histories - git push -u origin main || echo "No changes to push" - - - name: Commit collection .tsv to preview - if: ${{ inputs.render-type == 'preview' }} - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - git add --force resources/collection.tsv || echo "No changes to commit" - git commit -m 'Add collection file' || echo "No changes to commit" - git fetch - git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} --allow-unrelated-histories - git push --force origin $branch_name || echo "No changes to commit" diff --git a/.github/workflows/check-url.yml b/.github/workflows/check-url.yml new file mode 100644 index 00000000..7c1326c5 --- /dev/null +++ b/.github/workflows/check-url.yml @@ -0,0 +1,117 @@ +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_type: urls + error_min: 1 + + - 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 spell check file + 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 88dc705a..faa83ccd 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@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 00000000..b1cdc472 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,90 @@ + +# Candace Savonen Apr 2022 + +name: Build Docker Image + +on: + workflow_dispatch: + inputs: + directory: + required: true + type: string + tag: + required: true + type: string + dockerhubpush: + description: 'Push to Dockerhub?' + required: false + default: 'false' + type: string + secrets: + GH_PAT: + required: true + DOCKERHUB_USERNAME: + required: false + DOCKERHUB_TOKEN: + required: false + +jobs: + + build-docker: + name: Build Docker image + runs-on: ubuntu-latest + + steps: + - name: checkout repo + uses: actions/checkout@v4 + + - name: Verify Dockerfiles changed? + uses: tj-actions/verify-changed-files@v17 + id: verify-changed-files + with: + files: | + ${{ inputs.directory }}/Dockerfile + ${{ inputs.directory }}/github_package_list.tsv + + - name: Login as jhudsl-robot + run: | + git config --local user.email "itcrtrainingnetwork@gmail.com" + git config --local user.name "jhudsl-robot" + + # 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- + + - name: Set up Docker Build + uses: docker/setup-buildx-action@v1 + + - name: Get token + run: echo ${{ secrets.GH_PAT }} > ${{ inputs.directory }}/git_token.txt + + - name: Build Docker image + uses: docker/build-push-action@v2 + with: + push: false + load: true + context: ${{ inputs.directory }} + file: ${{ inputs.directory }}/Dockerfile + tags: ${{ inputs.tag }} + + # Login to Dockerhub + - name: Login to DockerHub + if: ${{ 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: ${{ inputs.dockerhubpush != 'false' }} + run: docker push ${{ inputs.tag }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 7a82f735..9b3ece7a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,5 @@ -# Candace Savonen Dec 2021 -# Updated May 2023 +# Candace Savonen 2021 +# Updated May 2025 name: Pull Request @@ -31,76 +31,67 @@ jobs: # Make the branch fresh - 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 --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 --set-upstream origin $branch_name + git push --set-upstream origin $branch_name || echo branch exists remotely shell: bash - - name: Check if this is a private repository - id: public_repository - run: | - public=$(curl -Is https://github.com/${GITHUB_REPOSITORY} | head -1 | tr -dc '0-9') - if [ $public -eq 2200 ];then - public='true' - echo 'public repository' - else - public='false' - echo 'private repository' - fi - echo ::set-output name=public::$public - shell: bash outputs: - public_repository: "${{ steps.public_repository.outputs.public }}" + 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 }}" - build-collection: - name: Build Collection - needs: yaml-check - uses: ./.github/workflows/build-collection.yml - with: - render-type: 'preview' - repository: $GITHUB_REPOSITORY - image-name: ${{needs.yaml-check.outputs.rendering_docker_image}} - secrets: - gh_pat: ${{ secrets.GH_PAT }} - - spell-check: - name: Check spelling +########################## Make the error reports ############################## + ottr-reports: + name: Run Reports 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 - secrets: - gh_pat: ${{ secrets.GH_PAT }} - - url-check: - name: Check URLs + 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 - 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 - secrets: - gh_pat: ${{ secrets.GH_PAT }} - - render-preview: - name: Render preview - needs: [yaml-check, build-collection] runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_style_code == 'true'}} container: - image: ${{needs.yaml-check.outputs.rendering_docker_image}} - if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}} + image: jhudsl/base_ottr:main steps: - name: Checkout files @@ -108,102 +99,54 @@ jobs: with: fetch-depth: 0 - # Set up git checkout - - name: Set up git checkout + - name: Run styler + 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 config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local 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 - - # We want a fresh run of the renders each time - - name: Delete old docs/* - run: rm -rf docs/* - - # Now we want to render Rmd -> html - - name: Convert Rmd to html - id: bookdown - run: | - Rscript scripts/build.R - - # 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 "devtools::install_github('jhudsl/ottrpal', upgrade = 'never'); ottrpal::render_without_toc()" - env: - GITHUB_PAT: ${{ secrets.GH_PAT }} - - # 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 + git add \*md + git commit -m 'Style *mds' || echo "No changes to commit" + git push origin || echo "No changes to commit" - # 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 +############################# Readability Report ################################### - - name: Find Comment - uses: peter-evans/find-comment@v2 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: latest commit + readability-report: + name: Readability report + needs: yaml-check + runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_readability == 'true'}} - - 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") - echo "bookdown_link=$bookdown_link" >> $GITHUB_OUTPUT - echo "tocless_link=$tocless_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 + steps: + - name: Checkout repo + uses: actions/checkout@v4 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 }}) - _Note that `DT::datatable()` content does not appear in preview._ - - _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 + fetch-depth: 0 + + - name: Readability report + uses: Rebilly/lexi@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. + github-token: ${{ secrets.GH_PAT }} + glob: '**/*.md' - _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace +############################# 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 + + 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 new file mode 100644 index 00000000..344b523e --- /dev/null +++ b/.github/workflows/render-all.yml @@ -0,0 +1,53 @@ +# Candace Savonen 2021 +# Updated April 2025 + +name: Render website + +on: + workflow_dispatch: + push: + branches: [ main, staging ] + paths: + - '*.qmd' + - '*.Rmd' + - assets/* + - quizzes/* + +jobs: + + yaml-check: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # 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_website: "${{ env.RENDER_WEBSITE }}" + rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" + + render-website: + name: Render website + needs: yaml-check + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - 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}} diff --git a/.github/workflows/render-site.yml b/.github/workflows/render-site.yml deleted file mode 100644 index 9db48916..00000000 --- a/.github/workflows/render-site.yml +++ /dev/null @@ -1,107 +0,0 @@ - -# It was adapted by Candace Savonen for the OTTR_template https://github.com/jhudsl/OTTR_Template. - -# This code was adapted by Carrie Wright to enable automated rendering of the site associated with this repository - -# +---------------- minute (0 - 59) -# | +------------- hour (0 - 23) -# | | +---------- day of month (1 - 31) -# | | | +------- month (1 - 12) -# | | | | +---- day of week (0 - 6) (Sunday=0 or 7) -# | | | | | -# * * * * * command to be executed - -name: Render html - -on: - workflow_dispatch: - schedule: - - cron: "0 3 * * 0" - push: - branches: - - main - paths: - - '**.Rmd' - - collection.tsv - -jobs: - yaml-check: - name: Load user automation choices - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - # 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 }}" - - build-collection: - name: Build Collection - needs: yaml-check - uses: ./.github/workflows/build-collection.yml - with: - render-type: 'main' - repository: $GITHUB_REPOSITORY - image-name: ${{needs.yaml-check.outputs.rendering_docker_image}} - secrets: - gh_pat: ${{ secrets.GH_PAT }} - - render-main: - runs-on: ubuntu-latest - # install.packages("remotes") # in case we decide not to go with the container... - # remotes::install_cran("rmarkdown") - # remotes::install_deps(dependencies = TRUE) - needs: [yaml-check, build-collection] - container: - image: ${{needs.yaml-check.outputs.rendering_docker_image}} - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: checkout - uses: actions/checkout@v4 - with: - # get the full repo - fetch-depth: 0 - # use github PAT - token: ${{ secrets.GH_PAT }} - - # We want a fresh run of the renders each time - - name: Delete old docs/* - run: rm -rf docs/* - - # Now we want to render Rmd -> html - - name: Convert Rmd to html - id: bookdown - run: | - Rscript scripts/build.R - - # 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 "devtools::install_github('jhudsl/ottrpal', upgrade = 'never'); ottrpal::render_without_toc()" - env: - GITHUB_PAT: ${{ secrets.gh_pat }} - - # Commit the rendered site files - html files and site_libs files - - name: Commit rendered site files - run: | - git config --global --add safe.directory ${GITHUB_WORKSPACE} - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - git config --global pull.ff true - git add . --force - git commit -m 'Render site' || echo "No changes to commit" - git pull --allow-unrelated-histories --strategy-option=ours - git push origin main || echo "No changes to push" From 4996cd3b0fd532b9c74c719191ec8404a2159a8f Mon Sep 17 00:00:00 2001 From: jhudsl-robot Date: Fri, 6 Jun 2025 21:06:31 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=94=84=20Created=20local=20'.github/w?= =?UTF-8?q?orkflows/render-site.yml'=20from=20remote=20'.github/workflows/?= =?UTF-8?q?render-all.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release-renderActionTry2 --- .github/workflows/render-site.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/render-site.yml diff --git a/.github/workflows/render-site.yml b/.github/workflows/render-site.yml new file mode 100644 index 00000000..344b523e --- /dev/null +++ b/.github/workflows/render-site.yml @@ -0,0 +1,53 @@ +# Candace Savonen 2021 +# Updated April 2025 + +name: Render website + +on: + workflow_dispatch: + push: + branches: [ main, staging ] + paths: + - '*.qmd' + - '*.Rmd' + - assets/* + - quizzes/* + +jobs: + + yaml-check: + name: Load user automation choices + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + # 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_website: "${{ env.RENDER_WEBSITE }}" + rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}" + + render-website: + name: Render website + needs: yaml-check + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GH_PAT }} + + - 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}} From 89a595b1ff546f672d1ce1c0f1432203727f9031 Mon Sep 17 00:00:00 2001 From: jhudsl-robot Date: Fri, 6 Jun 2025 21:06:31 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=84=20Synced=20local=20'config=5Fa?= =?UTF-8?q?utomation.yml'=20with=20remote=20'config=5Fautomation.yml'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release-renderActionTry2 --- config_automation.yml | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/config_automation.yml b/config_automation.yml index 9491650b..3bf069a8 100644 --- a/config_automation.yml +++ b/config_automation.yml @@ -1,28 +1,34 @@ +### 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: no +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: 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 +render-website: rmd_web # What docker image should be used for rendering? # The default is jhudsl/base_ottr:main -rendering-docker-image: 'jhudsl/base_ottr:tidy4.3.2' +rendering-docker-image: 'jhudsl/base_ottr:main'