Last active
August 27, 2023 03:00
-
-
Save VeckoTheGecko/7b6bb062135e59fbc9c5703c48435f5f to your computer and use it in GitHub Desktop.
Easy URL checking GitHub Action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check URL Status | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: 0 0 * * 0 | |
env: | |
LINK_TRACKING_ISSUE_NUMBER: 322 | |
permissions: | |
issues: write | |
jobs: | |
check-urls: | |
if: ${{ !github.event.repository.fork }} | |
env: | |
LYCHEE_REPORT_FILE: ./lychee/out.md | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Link Checker | |
id: lychee | |
uses: lycheeverse/[email protected] | |
- name: Read Lychee report | |
if: env.lychee_exit_code != 0 | |
id: readReport | |
run: | | |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) | |
echo "FILE_CONTENT<<$EOF" >> $GITHUB_OUTPUT | |
echo "$(cat ${{ env.LYCHEE_REPORT_FILE }})" >> $GITHUB_OUTPUT | |
echo "$EOF" >> $GITHUB_OUTPUT | |
- run: echo "${{ steps.readReport.outputs.FILE_CONTENT }}" | |
- name: Update link tracking issue (update invalid links) | |
if: env.lychee_exit_code != 0 | |
uses: actions-cool/issues-helper@v3 | |
with: | |
actions: "update-issue" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ env.LINK_TRACKING_ISSUE_NUMBER }} | |
state: "open" | |
body: ${{ steps.readReport.outputs.FILE_CONTENT }} | |
update-mode: "replace" | |
- name: Update link tracking issue (no invalid links) | |
if: env.lychee_exit_code == 0 | |
uses: actions-cool/issues-helper@v3 | |
with: | |
actions: "update-issue" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
issue-number: ${{ env.link_tracking_issue_number }} | |
state: "closed" | |
body: "No invalid links found! 🤖" | |
update-mode: "replace" | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: lychee-report | |
path: ${{ env.LYCHEE_REPORT_FILE }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This GitHub Action workflow checks the statuses of URLs within a repository, generating a report, and updating an issue with report results (by updating the issue body). This allows for the automated testing an monitoring of links in a non-intrusive way (i.e. without failing CI) with good oversight.
Steps:
LINK_TRACKING_ISSUE_NUMBER
with issue numberOther notes:
actions-cool/issues-helper
, something about security [1])Screenshot of updated issue: