Skip to content

Commit

Permalink
Update url checker
Browse files Browse the repository at this point in the history
  • Loading branch information
avahoffman committed Oct 27, 2023
1 parent 9e5322a commit 07ccd52
Showing 1 changed file with 5 additions and 81 deletions.
86 changes: 5 additions & 81 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,88 +181,12 @@ jobs:
url-check:
name: Check URLs
needs: yaml-check
runs-on: ubuntu-latest
if: ${{needs.yaml-check.outputs.toggle_url_check == 'yes'}}
container:
image: jhudsl/course_template:main

steps:
- name: checkout repo
uses: actions/checkout@v3

- name: Configure git
run: |
git config --local user.email "[email protected]"
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

- name: URLs checker
id: url_errors
run: |
chk_results=$(Rscript scripts/url-check.R)
echo $chk_results
echo "url_results=$chk_results" >> $GITHUB_OUTPUT
- name: Commit URL check
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
git add --force check_reports/url_checks.tsv || echo "No changes to commit"
git commit -m 'Add URL check file' || echo "No changes to commit"
git fetch
git push origin $branch_name || echo "No changes to commit"
- name: Build components of the spell check comment
id: build-components
env:
GH_PAT: ${{ secrets.GH_PAT }}
run: |
branch_name='preview-${{ github.event.pull_request.number }}'
url_errors=https://raw.githubusercontent.com/${GITHUB_REPOSITORY}/$branch_name/check_reports/url_checks.tsv
echo "time=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "commit_id=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "url_errors=$url_errors" >> $GITHUB_OUTPUT
# Handle the commenting
- name: Find Comment
uses: peter-evans/[email protected]
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: broken URLs

- name: URL errors!
if: ${{ steps.url_errors.outputs.url_results > 0 }}
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
:warning: There are broken URLs that need to be addressed. [Read this guide for more info](https://github.com/jhudsl/OTTR_Template/wiki/How-to-set-up-and-customize-GitHub-actions-robots#check-for-broken-urls).
[Download the errors here.](${{ steps.build-components.outputs.url_errors }})
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace

- name: Check URL results - fail if too many errors
if: ${{ steps.url_errors.outputs.url_results > 0 }}
run: exit 1

- name: No URL errors
if: ${{ steps.url_errors.outputs.url_results == 0 }}
uses: peter-evans/[email protected]
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
No broken URLs detected! :tada:
_Comment updated at ${{ steps.build-components.outputs.time }} with changes from ${{ steps.build-components.outputs.commit_id }}_
edit-mode: replace
uses: jhudsl/ottr-reports/.github/workflows/report-maker.yml@main
with:
check_type: urls
error_min: 0
gh_pat: secrets.GH_PAT

render-preview:
name: Render preview
Expand Down

0 comments on commit 07ccd52

Please sign in to comment.