|
| 1 | +name: Check URL Status |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: 0 0 * * 0 # run at midnight every Sunday |
| 7 | + |
| 8 | +env: |
| 9 | + LINK_TRACKING_ISSUE_NUMBER: 85 |
| 10 | + |
| 11 | +permissions: |
| 12 | + issues: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + check-urls: |
| 16 | + if: ${{ !github.event.repository.fork }} |
| 17 | + env: |
| 18 | + LYCHEE_REPORT_FILE: ./lychee/out.md |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Link Checker |
| 24 | + id: lychee |
| 25 | + uses: lycheeverse/[email protected] |
| 26 | + |
| 27 | + - name: Read Lychee report |
| 28 | + if: env.lychee_exit_code != 0 |
| 29 | + id: readReport |
| 30 | + run: | |
| 31 | + EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) |
| 32 | + echo "FILE_CONTENT<<$EOF" >> $GITHUB_OUTPUT |
| 33 | + echo "$(cat ${{ env.LYCHEE_REPORT_FILE }})" >> $GITHUB_OUTPUT |
| 34 | + echo "$EOF" >> $GITHUB_OUTPUT |
| 35 | + - run: echo "${{ steps.readReport.outputs.FILE_CONTENT }}" |
| 36 | + - name: Update link tracking issue (update invalid links) |
| 37 | + if: env.lychee_exit_code != 0 |
| 38 | + uses: actions-cool/issues-helper@v3 |
| 39 | + with: |
| 40 | + actions: 'update-issue' |
| 41 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + issue-number: ${{ env.LINK_TRACKING_ISSUE_NUMBER }} |
| 43 | + state: 'open' |
| 44 | + body: ${{ steps.readReport.outputs.FILE_CONTENT }} |
| 45 | + update-mode: 'replace' |
| 46 | + |
| 47 | + - name: Update link tracking issue (no invalid links) |
| 48 | + if: env.lychee_exit_code == 0 |
| 49 | + uses: actions-cool/issues-helper@v3 |
| 50 | + with: |
| 51 | + actions: 'update-issue' |
| 52 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + issue-number: ${{ env.LINK_TRACKING_ISSUE_NUMBER }} |
| 54 | + state: 'closed' |
| 55 | + body: 'No invalid links found! 🤖' |
| 56 | + update-mode: 'replace' |
| 57 | + |
| 58 | + - name: Upload artifact |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: lychee-report |
| 62 | + path: ${{ env.LYCHEE_REPORT_FILE }} |
0 commit comments