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/docker-test.yml b/.github/workflows/docker-test.yml index 6d786f4..b1cdc47 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -33,10 +33,10 @@ jobs: steps: - name: checkout repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Verify Dockerfiles changed? - uses: tj-actions/verify-changed-files@v8.8 + uses: tj-actions/verify-changed-files@v17 id: verify-changed-files with: files: | diff --git a/.github/workflows/file-automatic-issues.yml b/.github/workflows/file-automatic-issues.yml new file mode 100644 index 0000000..55f5baa --- /dev/null +++ b/.github/workflows/file-automatic-issues.yml @@ -0,0 +1,43 @@ +# 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 Website + +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_Website' + steps: + - name: checkout repo + uses: actions/checkout@v4 + + # 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 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0fa603b..70a1eab 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,5 @@ # Candace Savonen Dec 2021 -# Updated April 2023 +# Updated Aug 2024 name: Pull Request on: @@ -13,9 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 + token: ${{ secrets.GH_PAT }} # Use the yaml-env-action action. - name: Load environment from YAML @@ -25,17 +26,19 @@ jobs: # Delete the branch if this has been run before - name: Delete branch locally and remotely - run: git push origin --delete preview-${{ github.event.pull_request.number }} || echo "No branch to delete" + 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 --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.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 --force --set-upstream origin $branch_name shell: bash outputs: @@ -71,21 +74,21 @@ jobs: 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: - name: Checkout files - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # 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.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 @@ -110,21 +113,24 @@ jobs: echo site status ${{steps.site.outcome}} exit 1 - # Commit the rendered website files - - name: Commit rendered website files to preview branch + - 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 -- '*.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 + 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@v1 + uses: peter-evans/find-comment@v3 id: fc with: issue-number: ${{ github.event.pull_request.number }} @@ -136,26 +142,31 @@ jobs: 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") - 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 + 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@v1 + uses: peter-evans/create-or-update-comment@v3 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 }}) + :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 }}) - _Updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ + \* 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@v1 + uses: peter-evans/create-or-update-comment@v3 with: comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} diff --git a/.github/workflows/render-site.yml b/.github/workflows/render-site.yml index 508c0b1..d5d6415 100644 --- a/.github/workflows/render-site.yml +++ b/.github/workflows/render-site.yml @@ -15,10 +15,8 @@ on: - '**.Rmd' - styles.css - _site.yml - - subdir_html/*.Rmd - resources/images/*.png - resources/images/favicon.ico - - site_libs/* jobs: yaml-check: @@ -26,7 +24,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 @@ -43,11 +41,11 @@ jobs: runs-on: ubuntu-latest 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: + + steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # get the full repo fetch-depth: 0 @@ -72,11 +70,14 @@ jobs: exit 1 # Commit the rendered site files - html files and site_libs files +# The git reset step will remove any other files created in this workflow, such as API keys - name: Commit rendered site files run: | - git config --system --add safe.directory $GITHUB_WORKSPACE - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" + 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' git add --force docs/* git commit -m 'Render site' || echo "No changes to commit" + git reset --hard HEAD + git pull --rebase --allow-unrelated-histories --strategy-option=ours git push origin main || echo "No changes to push" diff --git a/config_automation.yml b/config_automation.yml index 12d9dd0..1a1a577 100644 --- a/config_automation.yml +++ b/config_automation.yml @@ -12,6 +12,8 @@ spell-check: yes style-code: yes # 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 @@ -19,6 +21,10 @@ render-bookdown: yes render-leanpub: yes 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: TRUE + # What docker image should be used for rendering? # The default is jhudsl/base_ottr:main rendering-docker-image: 'jhudsl/base_ottr:main'