-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use composite action for issue creation #131
Changes from all commits
5886c61
70a220f
66e9a66
274942d
1ace38e
97aa116
14eb799
981f565
99e8691
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
lycheeverse/lychee-action@.* | ||
https://github.com/org/repo | ||
https://francoisbest.com |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,6 @@ | |
|
||
Quickly check links in Markdown, HTML, and text files using [lychee]. | ||
|
||
When used in conjunction with [Create Issue From | ||
File](https://github.com/peter-evans/create-issue-from-file), issues will be | ||
created when the action finds link problems. | ||
|
||
## Usage | ||
|
||
Here is a full example of a GitHub workflow file: | ||
|
@@ -32,18 +28,19 @@ jobs: | |
- uses: actions/checkout@v3 | ||
|
||
- name: Link Checker | ||
id: lychee | ||
uses: lycheeverse/[email protected] | ||
uses: lycheeverse/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: Create Issue From File | ||
if: steps.lychee.outputs.exit_code != 0 | ||
uses: peter-evans/create-issue-from-file@v3 | ||
with: | ||
title: Link Checker Report | ||
content-filepath: ./lychee/out.md | ||
labels: report, automated issue | ||
``` | ||
|
||
Issue creation can optionally be disabled | ||
|
||
```yaml | ||
- name: Link Checker | ||
uses: lycheeverse/[email protected] | ||
with: | ||
createIssue: false | ||
``` | ||
|
||
### Alternative approach: | ||
|
@@ -181,6 +178,8 @@ This action is based on | |
lychee (written in Rust) instead of liche (written in Go) for link checking. For | ||
a comparison of both tools, check out this [comparison | ||
table](https://github.com/lycheeverse/lychee#features). | ||
We also use [create-issue-from-file](https://github.com/peter-evans/create-issue-from-file) | ||
to create issues. | ||
|
||
## License | ||
|
||
|
@@ -196,4 +195,4 @@ at your option. | |
[lychee-args]: https://github.com/lycheeverse/lychee#commandline-parameters | ||
[troubleshooting]: https://github.com/lycheeverse/lychee/blob/master/docs/TROUBLESHOOTING.md | ||
[security]: https://francoisbest.com/posts/2020/the-security-of-github-actions | ||
[dependabot]: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
[dependabot]: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,36 +6,55 @@ inputs: | |||||||||||||||||||||||||
default: "--verbose --no-progress './**/*.md' './**/*.html'" | ||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
format: | ||||||||||||||||||||||||||
description: "summary output format (e.g. json)" | ||||||||||||||||||||||||||
description: "Summary output format (e.g. json)" | ||||||||||||||||||||||||||
default: "markdown" | ||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
output: | ||||||||||||||||||||||||||
description: "summary output file path" | ||||||||||||||||||||||||||
default: "lychee/out.md" | ||||||||||||||||||||||||||
description: "Summary output file path" | ||||||||||||||||||||||||||
default: "summary.md" | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the working directory for this action is likely a git repo, and other steps in the job (using this composite as a single step) may also process content at this location. You should not write into it and instead prefer using a temporary location?
Suggested change
https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context
|
||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
fail: | ||||||||||||||||||||||||||
description: "fail entire pipeline on error (i.e. when lychee exit code is not 0)" | ||||||||||||||||||||||||||
description: "Fail entire pipeline on error (i.e. when lychee exit code is not 0)" | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||
default: false | ||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
jobSummary: | ||||||||||||||||||||||||||
description: "write Github job summary at the end of the job (written on Markdown output only)" | ||||||||||||||||||||||||||
description: "Write Github job summary at the end of the job (written on Markdown output only)" | ||||||||||||||||||||||||||
default: true | ||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
lycheeVersion: | ||||||||||||||||||||||||||
description: "use custom version of lychee link checker" | ||||||||||||||||||||||||||
description: "Use custom version of lychee link checker" | ||||||||||||||||||||||||||
default: 0.10.0 | ||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
createIssue: | ||||||||||||||||||||||||||
description: "Create Github issue if link check fails" | ||||||||||||||||||||||||||
default: true | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be opt-in. I would not want issues being created by default when using this to lint PRs. The only time it makes sense is for a scheduled recurring job to notify maintainers. When that is desired it should be looked up and opt-in, not occur by default which would be surprising for an action that supports other use-cases. Additionally it'd likely fail on PRs (from third-party contributors, due to running in an insecure context required permissions would be missing).
Suggested change
|
||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
issueTitle: | ||||||||||||||||||||||||||
description: "Title of Github issue which will be created if link check fails" | ||||||||||||||||||||||||||
default: Link Checker Report | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be better to scope the issue with a prefix that indicates in the title it's a CI issue, and more specific hint of the content (since while it does contain a report, it's only being reported when failures are caught?):
Suggested change
|
||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
issueLabels: | ||||||||||||||||||||||||||
description: "Attach labels to Github issue" | ||||||||||||||||||||||||||
default: links, report, automated issue | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, I'd rather not have an action add a bunch of labels polluting a projects own labels (a project I maintain has plenty already and these would be unwanted noise in the way of manual triage). Especially if the action is not even using the labels for any purpose... that should be opt-in (no default, show the feature off in examples instead). If you added the other action which can lookup an issue number by label (picks the issue result sorted by last updated), then something like this might be useful:
Suggested change
Otherwise avoid default labels, let the user choose labels that are relevant to their project for this feature. |
||||||||||||||||||||||||||
required: false | ||||||||||||||||||||||||||
issueRepository: | ||||||||||||||||||||||||||
description: 'The target GitHub repository for creating issues' | ||||||||||||||||||||||||||
default: ${{ github.repository }} | ||||||||||||||||||||||||||
issueNumber: | ||||||||||||||||||||||||||
description: 'The issue number of an existing issue to update' | ||||||||||||||||||||||||||
Comment on lines
+32
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worthwhile for maintainers (beyond yourself) to grok this composite action easier if the scope of inputs is less vague. A simple comment should help with that since these are all sub-inputs to the + # These inputs only valid when `createIssue: true`
issueTitle:
description: "Title of Github issue which will be created if link check fails"
default: Link Checker Report
required: false
issueLabels:
description: "Attach labels to Github issue"
default: links, report, automated issue
required: false
issueRepository:
description: 'The target GitHub repository for creating issues'
default: ${{ github.repository }}
issueNumber:
description: 'The issue number of an existing issue to update'
Comment on lines
+40
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two inputs are missing
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
runs: | ||||||||||||||||||||||||||
using: "composite" | ||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||
- name: install lychee | ||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||
- run: | | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was the step name dropped? |
||||||||||||||||||||||||||
curl -LO 'https://github.com/lycheeverse/lychee/releases/download/v${{ inputs.LYCHEEVERSION }}/lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz' | ||||||||||||||||||||||||||
tar -xvzf lychee-v${{ inputs.LYCHEEVERSION }}-x86_64-unknown-linux-gnu.tar.gz | ||||||||||||||||||||||||||
chmod 755 lychee | ||||||||||||||||||||||||||
mv lychee /usr/local/bin/lychee | ||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||
- run: ${{ github.action_path }}/entrypoint.sh | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
- id: lychee | ||||||||||||||||||||||||||
run: ${{ github.action_path }}/entrypoint.sh | ||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||
#https://github.com/actions/runner/issues/665 | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to apply to the entire |
||||||||||||||||||||||||||
INPUT_GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }} | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the point of this ENV? You do not appear to use |
||||||||||||||||||||||||||
|
@@ -46,6 +65,15 @@ runs: | |||||||||||||||||||||||||
INPUT_JOBSUMMARY: ${{ inputs.JOBSUMMARY }} | ||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
- if: inputs.CREATEISSUE && steps.lychee.outputs.exit_code != 0 | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to check failure status and step outcome, rather than
Suggested change
Remember this would involve In saying that,
And your issue creation is probably only interested in Presently you handle a related scenario that Lines 20 to 22 in 76ab977
Ideally an output to communicate the link failure is more than `continue-on-error: true` (_I need to verify some information_)Alternatively with I need to check if
Suggested change
Finally with consideration for other failures that could occur in the action.. (_I need to verify some information_)You may want the workflow run to fail by not using Bringing us closer to the condition you have used:
Suggested change
I think, a workflow that has other steps involved unrelated to link checking should be in separate jobs, where they would not be affected and a failed status is fine then. It's then the decision of if running
Personally, if I'm having an issue opened for failed links, the job worked correctly, the job was not a failure (the step itself can be), and I'd rather the job didn't exit and notify me of such. However for a PR, no issue is needed, and failed links is actionable as either a failed job (lint), or having another step take that information and do something with it on the PR (eg: adding/updating a comment, similar to this issue support). That decision can be handled with |
||||||||||||||||||||||||||
uses: peter-evans/create-issue-from-file@v4 | ||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||
title: ${{ inputs.ISSUETITLE }} | ||||||||||||||||||||||||||
labels: ${{ inputs.ISSUELABELS }} | ||||||||||||||||||||||||||
repository: ${{ inputs.ISSUEREPOSITORY }} | ||||||||||||||||||||||||||
issue-number: ${{ inputs.ISSUENUMBER }} | ||||||||||||||||||||||||||
content-filepath: ${{ inputs.OUTPUT }} | ||||||||||||||||||||||||||
Comment on lines
+68
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the
And related docs for
Both are about ENV creation of inputs, I'm not sure why you're referencing the inputs upper-case here? Here you are using the Just pointing this out as I'm not sure what you're referencing to take that approach. Related note regarding differences with action output handling for composite actionsIf you need to provide outputs from composite action steps, keep in mind the syntax is a bit different:
Example from docs: outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-id }}
runs:
using: "composite"
steps:
- id: random-number-generator
run: echo "::set-output name=random-id::$(echo $RANDOM)"
shell: bash |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
branding: | ||||||||||||||||||||||||||
icon: "external-link" | ||||||||||||||||||||||||||
color: "purple" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to show off / mention other supported features too?