diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e21d8a76..69d993b7 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -62,7 +62,7 @@ jobs: name: Check spelling needs: yaml-check if: ${{needs.yaml-check.outputs.toggle_spell_check == 'yes'}} - uses: ./.github/workflows/report-maker.yml + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main with: check_type: spelling error_min: 3 @@ -72,7 +72,7 @@ jobs: name: Check URLs needs: yaml-check if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}} - uses: ./.github/workflows/report-maker.yml + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main with: check_type: urls error_min: 0 @@ -82,7 +82,7 @@ jobs: name: Check quiz formatting if: ${{needs.yaml-check.outputs.toggle_quiz_check == 'yes'}} needs: yaml-check - uses: ./.github/workflows/report-maker.yml + uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main with: check_type: quiz_format error_min: 0 diff --git a/.github/workflows/report-maker.yml b/.github/workflows/report-maker.yml deleted file mode 100644 index 074a5eb9..00000000 --- a/.github/workflows/report-maker.yml +++ /dev/null @@ -1,126 +0,0 @@ -# Candace Savonen March 2022 - -# This calls the report makers but then also handles the commenting - -name: Run error checker - -on: - workflow_call: - inputs: - check_type: - required: true - type: string - error_min: - default: 0 - type: number - gh_pat: - type: string - required: true - -jobs: - error-check: - runs-on: ubuntu-latest - container: - image: jhudsl/course_template:main - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - ref: 'preview-${{ github.event.pull_request.number }}' - - - name: Run the check - uses: jhudsl/ottr-reports@main - id: check_results - with: - check_type: ${{ inputs.check_type }} - error_min: ${{ inputs.error_min }} - - - name: Declare report name - id: setup - run: | - echo ::set-output name=report_name::$(basename ${{ steps.check_results.outputs.report_path }}) - - if ${{ contains(inputs.check_type, 'spelling') }} ;then - echo ::set-output name=error_name::'spelling errors' - elif ${{ contains(inputs.check_type, 'urls') }} ;then - echo ::set-output name=error_name::'broken urls' - elif ${{ contains(inputs.check_type, 'quiz_format') }} ;then - echo ::set-output name=error_name::'quiz formatting errors' - fi - -############################# Handle commenting ################################ - - - name: Build components of the spell check comment - id: build-components - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - echo ::set-output name=time::$(date +'%Y-%m-%d') - echo ::set-output name=commit_id::$GITHUB_SHA - echo ::set-output name=error_url::https://raw.githubusercontent.com/$GITHUB_REPOSITORY/$branch_name/${{ steps.check_results.outputs.report_path }} - shell: bash - - - name: Commit check files to branch - id: commit - run: | - branch_name='preview-${{ github.event.pull_request.number }}' - - git config --local user.email "itcrtrainingnetwork@gmail.com" - git config --local user.name "jhudsl-robot" - - git add --force . || echo "No changes to commit" - git commit -m 'Add check file' || echo "No changes to commit" - git fetch - git merge -s recursive --strategy-option=ours origin/${{ github.head_ref }} --allow-unrelated-histories - git push --force origin $branch_name || echo "No changes to commit" - - error_num=$(cat ${{ steps.check_results.outputs.report_path }} | wc -l) - error_num="$((error_num-1))" - echo ::set-output name=error_num::$error_num - shell: bash - - - name: Find Comment - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body-includes: ${{ steps.setup.outputs.error_name }} - - - name: There are errors! - if: ${{ steps.commit.outputs.error_num > inputs.error_min }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - :warning: ${{ steps.setup.outputs.error_name }} :warning: - There are ${{ steps.setup.outputs.error_name }} that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/Most-common-errors-and-pitfalls). - [Download the errors here.](${{ steps.build-components.outputs.error_url }}) - _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace - - - name: Fail if too many errors - if: ${{ steps.commit.outputs.error_num > inputs.error_min }} - run: | - echo ${{ steps.commit.outputs.error_num }} - exit 1 - shell: bash - - - name: Don't fail if not too many errors - if: ${{ steps.commit.outputs.error_num <= inputs.error_min }} - run: | - echo ${{ steps.commit.outputs.error_num }} - shell: bash - - - name: No errors - if: ${{ steps.commit.outputs.error_num <= inputs.error_min }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - issue-number: ${{ github.event.pull_request.number }} - body: | - No ${{ steps.setup.outputs.error_name }}! :tada: - _Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_ - edit-mode: replace