Skip to content

Commit

Permalink
fix(broken-links): init broken links checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Georges Bossert committed Oct 1, 2024
1 parent 9d345e7 commit 59be662
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/check-broken-links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Check Broken Links

on:
workflow_run:
workflows: ["Upload preview to OVH Object Storage"]
types:
- completed

jobs:
check-broken-links:
name: Check Broken Links
runs-on: ubuntu-latest

steps:
- name: Checkout main
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: '3.11'

- name: Download artifact
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "site.tar.gz"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/site.tar.gz.zip', Buffer.from(download.data));
- run: |
unzip site.tar.gz.zip
mkdir site
tar zxvf site.tar.gz -C ./site
- name: Get PR number
id: pr_number
run: echo "pr_number=$(cat site/.pr_number)" >> $GITHUB_OUTPUT

- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ steps.pr_number.outputs.pr_number }}
comment-author: github-actions[bot]
body-includes: Found broken links

# install linkchecker
- name: Install linkchecker
run: sudo apt-get install linkchecker

# execute linkchecker on docs.sekoia.io
- name: Check broken links
run: linkchecker --check-extern --no-follow-url="!://storage.gra.cloud.ovh.net/v1/AUTH_741841e1c7da4c50a76152cbc2609bd1/sekoiaio-documentation-previews" --ignore-url="github.com/SEKOIA-IO" --ignore-url="https://storage.gra.cloud.ovh.net/v1/AUTH_741841e1c7da4c50a76152cbc2609bd1/sekoiaio-documentation-previews/${{ steps.pr_number.outputs.pr_number }}/tip/" -o csv -F csv "https://storage.gra.cloud.ovh.net/v1/AUTH_741841e1c7da4c50a76152cbc2609bd1/sekoiaio-documentation-previews/${{ steps.pr_number.outputs.pr_number }}/getting_started/"

# execute python script to parse the csv file and get the broken links
- name: Parse broken links
run: python scripts/broken_links/create_issues.py linkchecker-out.csv

- name: Add comment to PR
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ steps.pr_number.outputs.pr_number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
Found broken links in preview environment !

0 comments on commit 59be662

Please sign in to comment.