-
Notifications
You must be signed in to change notification settings - Fork 252
workflow/verify links #819
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| name: pages-build-deployment | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| # TODO: Make better when we have added this to the verify-links workflow | ||
| # https://lychee.cli.rs/github_action_recipes/pull-requests/ | ||
| pull_request: | ||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
| jobs: | ||
| build: | ||
| name: Build Jekyll page | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v5 | ||
| - name: Build with Jekyll | ||
| uses: actions/jekyll-build-pages@v1 | ||
| - name: Upload Jekyll site for lychee URL checker | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: build | ||
| path: ./_site | ||
| if-no-files-found: error | ||
| retention-days: 7 | ||
| - name: Upload artifact for GitHub pages | ||
| if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | ||
| uses: actions/upload-pages-artifact@v4 | ||
| deploy: | ||
| name: Deploy to GitHub pages | ||
| if: github.event_name != 'pull_request' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| verify_links: | ||
| name: Verify website links still work | ||
| needs: build | ||
| uses: ./.github/workflows/verify-links.yml | ||
| permissions: | ||
| issues: write # required for peter-evans/create-issue-from-file | ||
| with: | ||
| create_issue: ${{ github.event_name != 'pull_request' }} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||
| name: Verify links | ||||||
|
|
||||||
| on: | ||||||
| # push: | ||||||
| # branches: | ||||||
| # - main | ||||||
| # - workflow/verify-links # TODO Remove before merging PR | ||||||
| repository_dispatch: | ||||||
| workflow_dispatch: | ||||||
| workflow_call: | ||||||
| inputs: | ||||||
| create_issue: | ||||||
| required: false | ||||||
| type: boolean | ||||||
| default: false | ||||||
| schedule: | ||||||
| - cron: "08 08 * * 1" | ||||||
|
|
||||||
| concurrency: | ||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||
| cancel-in-progress: true | ||||||
|
|
||||||
| jobs: | ||||||
| link_checker: | ||||||
| runs-on: ubuntu-latest | ||||||
| permissions: | ||||||
| issues: write # required for peter-evans/create-issue-from-file | ||||||
| steps: | ||||||
| - uses: actions/download-artifact@v5 | ||||||
| with: | ||||||
| name: "build" | ||||||
| path: "prod" | ||||||
|
|
||||||
| - name: Checkout lychee toml file | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| path: repo | ||||||
| sparse-checkout: '.lychee.toml' | ||||||
| sparse-checkout-cone-mode: false | ||||||
|
|
||||||
| - name: Restore lychee cache | ||||||
| uses: actions/cache@v4 | ||||||
| with: | ||||||
| path: .lycheecache | ||||||
| key: cache-lychee-${{ github.sha }} | ||||||
| restore-keys: cache-lychee- | ||||||
|
|
||||||
| - name: Link Checker | ||||||
| id: lychee | ||||||
| uses: lycheeverse/lychee-action@v2 | ||||||
| with: | ||||||
| fail: false | ||||||
| args: | | ||||||
| --root-dir "${{github.workspace}}/prod" | ||||||
| --config "${{github.workspace}}/repo/.lychee.toml" | ||||||
| . | ||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||
|
|
||||||
| - name: Find the last open report issue | ||||||
| if: | | ||||||
| steps.lychee.outputs.exit_code != 0 | ||||||
| && inputs.create_issue | ||||||
| id: last-issue | ||||||
| uses: micalevisk/last-issue-action@v2 | ||||||
|
Member
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 one seems to be dead for 2 years without releases and I am slightly concerned about supply chain attacks here. It essentially does one query which seems to be trivially rewritten in JavaScript in the workflow like we do for But then Getting the issue might be as simple as
Member
Author
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. We could use the hash for taking the release and update it with Renovate when there are new versions (if ever). Would at least ensure that the release itself is the one we expect.
Suggested change
But yeah might be better to use something like that if it works |
||||||
| with: | ||||||
| state: open | ||||||
| labels: link-checker | ||||||
|
|
||||||
| - name: Update or create issue report | ||||||
| if: | | ||||||
| steps.lychee.outputs.exit_code != 0 | ||||||
| && steps.last-issue.outputs.has-found == 'false' | ||||||
| && inputs.create_issue | ||||||
| uses: peter-evans/create-issue-from-file@v5 | ||||||
| with: | ||||||
| title: Broken links detected in docs 🔗 | ||||||
| content-filepath: ./lychee/out.md | ||||||
| issue-number: ${{ steps.last-issue.outputs.issue-number }} | ||||||
|
Member
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 no issue is found? Does this accept null?
Member
Author
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 is an optional field so yeah it would parse as not having provided any. In this repo I see that they were successful with this approach: So it should work for us too. Their approach is to keep the issue open and update it regardless if the link checker failed or not. Whereas in this PR I've set it so it opens an issue or updates an existing one if something fails. So there is a slight difference. They also have a step to close the issue which we could adopt (though theirs doesn't work atm due to their if-statement it seems). |
||||||
| token: ${{secrets.GITHUB_TOKEN}} | ||||||
| labels: link-checker | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Don't exceed max_concurrency = 1 until this is implemented | ||
| # https://github.com/lycheeverse/lychee/issues/989 | ||
| max_concurrency = 1 | ||
| retry_wait_time = 60 | ||
| skip_missing = true | ||
| exclude_all_private = true | ||
| exclude = [ | ||
| # '^https://linux.die.net', | ||
| # We have this as an example | ||
| "domain.tld", | ||
| # 'https://bodhi.fedoraproject.org/updates/cockpit-*', | ||
| # Not local but used with podman etc. | ||
| "0.0.0.0", | ||
| # Need to be authenticated with GitHub edits and fails with 404 instead of 403 | ||
| '^https:\/\/github.com\/cockpit-project\/cockpit\/wiki\/.*\/_edit', | ||
| # If we are checking files this will fail as it would match stuff like: | ||
| # `file:///blog/authors#name` | ||
| 'file:///.*#.*' | ||
| ] | ||
| cache = true | ||
| cache_exclude_status = "400..=599" | ||
| max_cache_age = "1d" | ||
|
|
||
| exclude_link_local = true | ||
| exclude_loopback = true | ||
| verbose = "debug" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
|
|
||
| lychee-container: | ||
| podman run --init -it -v .:/input:Z,ro lycheeverse/lychee --root-dir "/input/_site" --config "/input/.lychee.toml" /input/_site | ||
|
|
||
| .PHONY: lychee-container |
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.
Not sure if anyone watched scheduled jobs, for Cockpit we make issues. Owners will spot these issues but not sure if anyone else would.
Did you try running lychee locally? Because without any changes it generates this:
It also will require a GITHUB_TOKEN otherwise we run into rate limits.