Skip to content

Commit

Permalink
Update reporting functionality (#32)
Browse files Browse the repository at this point in the history
* Update CML syntax for link check diff report

* Add new reports and options

* Add remaining needed inputs, replace lychee hard-codes, add workflow_dispatch

* Add pull_request for testing

* Add useful test

* Fix useful test

* Add @latest

* Remove failure clause on issue creation

* Fix pattern

* Re-add failure check for report creation

* Fix rootURL option

* Remove rootURL option in favor of config

* Use different failure flow

* Fix default labels field

* Add a title

* Remove failing link for test purposes

* Remove test file and reset test fixture
  • Loading branch information
rogermparent authored Feb 6, 2023
1 parent 52b2ccf commit 1947eae
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
89 changes: 88 additions & 1 deletion .github/workflows/link-check-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,50 @@ name: Check all links in the repository
on:
workflow_call:
inputs:
failsOnly:
type: "boolean"
required: false
description: "If true, only reports failed links"
default: true
outputFile:
type: "string"
required: false
description: "The file the link check report will be written to before publishing"
default: "link-check-report.md"
config:
type: 'string'
description: 'The path to the link-check config file'
default: 'config/link-check/config.yml'
owner:
description:
The owner of repository to operate on if the event doesn't include it
required: false
type: string
default: '${{ github.event.repository.owner.login }}'
repo:
description:
The repository to operate on if the event doesn't include it
required: false
type: string
default: '${{ github.event.repository.name }}'
label:
description:
The label that will be used to identify existing link-check reports to
edit
required: false
type: string
default: link-check-all
labels:
description:
The labels that will be assigned to issues created by this workflow
required: false
type: string
default: link-check-all
title:
description: The title of the issue created by this workflow
required: false
type: string
default: 'Link Checker Report'
jobs:
run:
name: Link Check All
Expand All @@ -14,6 +54,53 @@ jobs:
NODE_OPTIONS: '--max-http-header-size=65536'
steps:
- uses: actions/checkout@v3
- run: echo "# Link Check Report" > ${{ inputs.outputFile }}
- name: Run Link Check
id: check
run: npx repo-link-check -c ${{ inputs.config }}
run: |
npx repo-link-check@latest \
${{ inputs.failsOnly && '-f' || '' }} \
-c ${{ inputs.config }} \
>> ${{ inputs.outputFile }}
- name: Find latest open Link Check issue
uses: actions/github-script@v6
id: find-existing-comment
if: always()
env:
OWNER: ${{ inputs.owner }}
REPO: ${{ inputs.repo }}
LABEL: ${{ inputs.label }}
with:
script: |
const { OWNER, REPO, LABEL } = process.env
const options = {
owner: OWNER,
repo: REPO,
labels: LABEL,
state: "open",
creator: "github-actions[bot]",
sort: "created"
}
const issues = await github.rest.issues.listForRepo(options)
if(issues && issues.data && issues.data[0]) {
return issues.data[0].number
}
- name: Create or Update Issue
uses: peter-evans/create-issue-from-file@v4
if: failure()
with:
issue-number: ${{ steps.find-existing-comment.outputs.result }}
title: ${{ inputs.title }}
content-filepath: ${{ inputs.outputFile }}
labels: ${{ inputs.labels }}

- name: Close if Check Passes
uses: peter-evans/[email protected]
if: >-
success() &&
steps.find-existing-comment.outputs.result
with:
issue-number: ${{ steps.find-existing-comment.outputs.result }}
comment: The most recent link check passed!
9 changes: 6 additions & 3 deletions .github/workflows/link-check-deployment-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
required: false
description: "The file the link check report will be written to before publishing"
default: "link-check-report.md"
config:
type: 'string'
description: 'The path to the link-check config file'
default: 'config/link-check/config.yml'
jobs:
run:
name: Run
Expand All @@ -37,11 +41,10 @@ jobs:
npx repo-link-check \
${{ inputs.failsOnly && '-f' || '' }} \
-d ${{ inputs.branch }} \
-c config/link-check/config.yml \
-c ${{ inputs.config }} \
-r ${{ github.event.deployment.payload.web_url }} \
>> ${{ inputs.outputFile }}
- name: Create or update comment
run: cml send-comment --pr --update ${{ inputs.outputFile }}
run: cml comment update --watermark-title="Link Check Report" ${{ inputs.outputFile }}
env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions config/link-check/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fileIncludePatterns:
- ./test/*

0 comments on commit 1947eae

Please sign in to comment.