diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 05eb5ce3..25e37fb6 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,8 +12,10 @@ jobs: name: Load user automation choices runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout files uses: actions/checkout@v2 + with: + fetch-depth: 0 # Use the yaml-env-action action. - name: Load environment from YAML @@ -29,28 +31,6 @@ jobs: docker/Dockerfile docker/github_package_list.tsv - outputs: - toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" - toggle_spell_check: "${{ env.STYLE_AND_SP_CHECK }}" - toggle_url_check: "${{ env.URL_CHECKER }}" - toggle_render_preview: "${{ env.RENDER_PREVIEW }}" - toggle_docker_build: "${{ env.DOCKER_BUILD }}" - dockerfiles_changed: steps.verify-changed-files.outputs.files_changed - - style-n-check: - name: Check style and spelling - needs: yaml-check - runs-on: ubuntu-latest - if: ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}} - container: - image: jhudsl/course_template - - steps: - - name: Checkout files - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Configure git run: | git config --local user.email "itcrtrainingnetwork@gmail.com" @@ -70,6 +50,23 @@ jobs: fi shell: bash + outputs: + toggle_quiz_check: "${{ env.CHECK_QUIZZES }}" + toggle_spell_check: "${{ env.STYLE_AND_SP_CHECK }}" + toggle_url_check: "${{ env.URL_CHECKER }}" + toggle_render_preview: "${{ env.RENDER_PREVIEW }}" + toggle_docker_build: "${{ env.DOCKER_BUILD }}" + dockerfiles_changed: steps.verify-changed-files.outputs.files_changed + + style-n-check: + name: Check style and spelling + needs: yaml-check + runs-on: ubuntu-latest + if: ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}} + container: + image: jhudsl/course_template + + steps: - name: Run spell check id: spell_check_run run: | @@ -85,6 +82,9 @@ jobs: - name: Commit spell check errors run: | + git config --local user.email "itcrtrainingnetwork@gmail.com" + git config --local user.name "jhudsl-robot" + branch_name='preview-${{ github.event.pull_request.number }}' git add --force resources/spell_check_results.tsv git commit -m 'Add spell check file' || echo "No changes to commit" @@ -155,14 +155,6 @@ jobs: if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}} steps: - - name: checkout repo - uses: actions/checkout@v2 - - - name: Login as jhudsl-robot - run: | - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - - name: URLs-checker uses: urlstechie/urlchecker-action@master with: @@ -189,30 +181,6 @@ jobs: image: jhudsl/course_template if: ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}} steps: - - name: Checkout files - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Configure git - run: | - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - - branch_name='preview-${{ github.event.pull_request.number }}' - exists=$(git ls-remote https://${{ secrets.GH_PAT }}@github.com/$GITHUB_REPOSITORY $branch_name | wc -l | xargs) - if [[ $exists == 0 ]];then - echo branch doesnt exist - git checkout -b $branch_name - git push --set-upstream origin $branch_name - else - echo branch does exist - git fetch --all - git checkout $branch_name - git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} - fi - shell: bash - - name: Run quiz check id: quiz_check_run run: | @@ -226,18 +194,10 @@ jobs: - name: Commit quiz check errors run: | branch_name='preview-${{ github.event.pull_request.number }}' - git diff --name-only origin/main -- question_error_report.tsv >/dev/null && changes=true || changes=false - echo $changes - if $changes == true; then - git diff --name-only origin/$branch_name question_error_report.tsv >/dev/null && changes=true || changes=false - echo $changes - if $changes == true; then - git add --force question_error_report.tsv - git diff-index --quiet HEAD || git commit -m 'Add question error report file' - git pull --set-upstream origin $branch_name --allow-unrelated-histories - git push origin $branch_name - fi - fi + git add --force question_error_report.tsv + git commit -m 'Add question error report file' || echo "No changes to commit" + git pull --set-upstream origin $branch_name --allow-unrelated-histories + git push origin $branch_name || echo "No changes to commit" - name: Build components of the quiz check comment id: build-components @@ -294,40 +254,15 @@ jobs: image: jhudsl/course_template if: ${{needs.yaml-check.outputs.toggle_render_preview == 'yes'}} steps: - - name: Checkout files - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # Set up git checkout - - name: Set up git checkout - run: | - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - - branch_name='preview-${{ github.event.pull_request.number }}' - exists=$(git ls-remote https://${{ secrets.GH_PAT }}@github.com/$GITHUB_REPOSITORY $branch_name | wc -l | xargs) - if [[ $exists == 0 ]];then - echo branch doesnt exist - git checkout -b $branch_name - git push --set-upstream origin $branch_name - else - echo branch does exist - git fetch --all - git checkout $branch_name - git merge -s recursive --strategy-option=theirs origin/${{ github.head_ref }} - fi - - rm -r docs/* - shell: bash - # Run bookdown rendering - name: Run bookdown render id: bookdown - run: Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')" + run: | + rm -r docs/* + Rscript -e "bookdown::render_book('index.Rmd', output_format = 'all')" # Run TOC-less version - # Rendered content for Leanpub and Coursera is very similar. + # 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 @@ -346,9 +281,13 @@ jobs: - name: Commit rendered bookdown files to preview branch id: commit run: | + git config --local user.email "itcrtrainingnetwork@gmail.com" + git config --local user.name "jhudsl-robot" + branch_name='preview-${{ github.event.pull_request.number }}' git diff origin/main -- docs >/dev/null && changes=true || changes=false echo ::set-output name=changes::$changes + git add . --force git commit -m 'Render preview' || echo "No changes to commit" git pull --set-upstream origin $branch_name --allow-unrelated-histories @@ -411,22 +350,6 @@ jobs: if: ${{needs.yaml-check.outputs.toggle_docker_build == 'yes' && needs.yaml-check.outputs.dockerfiles_changed == 'true' && github.head_ref != 'repo-sync/OTTR_Template/default'}} steps: - - name: checkout repo - uses: actions/checkout@v2 - - - name: Verify Dockerfiles changed? - uses: tj-actions/verify-changed-files@v8.8 - id: verify-changed-files - with: - files: | - docker/Dockerfile - docker/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 @@ -454,3 +377,6 @@ jobs: context: docker file: docker/Dockerfile tags: jhudsl/course_template + + - name: Get token + run: rm -f docker/git_token.txt diff --git a/resources/screenshots/check-comments.png b/resources/screenshots/check-comments.png new file mode 100644 index 00000000..e7865931 Binary files /dev/null and b/resources/screenshots/check-comments.png differ diff --git a/resources/screenshots/gha-checks.png b/resources/screenshots/gha-checks.png new file mode 100644 index 00000000..3e965c33 Binary files /dev/null and b/resources/screenshots/gha-checks.png differ