Production #12
This file contains 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 broken links | |
on: | |
deployment: | |
# push: | |
# branches: | |
# - main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm install -g linkinator | |
- name: Check links | |
run: linkinator https://docs.pimlico.io -r --format json > links-report.json | |
- name: Prepare report | |
id: prepare-report | |
run: | | |
LENGTH=$(jq '[.links[] | select(.state == "BROKEN")] | length' links-report.json) | |
if [ "$LENGTH" -gt 0 ]; then | |
echo "send_report=true" >> $GITHUB_OUTPUT | |
else | |
echo "send_report=false" >> $GITHUB_OUTPUT | |
fi | |
REPORT_LIST=$(jq '[.links[] | select(.state == "BROKEN" and .status == 404) | "- `\(.url)` (status: `\(.status)`) on the page \(.parent)"] | join(" \n ")' links-report.json) | |
echo "report_list=$REPORT_LIST" >> $GITHUB_OUTPUT | |
- name: Send report | |
uses: slackapi/[email protected] | |
if: steps.prepare-report.outputs.send_report == 'true' | |
with: | |
channel-id: "#alerts-test" | |
slack-message: | | |
Broken links found in the docs: | |
${{ steps.prepare-report.outputs.report_list }} | |
# payload: | | |
# { | |
# "text": "Report", | |
# "blocks": [ | |
# { | |
# "type": "section", | |
# "text": { | |
# "type": "mrkdwn", | |
# "text": ${{ steps.prepare-report.outputs.report_list }} | |
# } | |
# } | |
# ] | |
# } | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |