Skip to content

Check links on Academy #606

Check links on Academy

Check links on Academy #606

Workflow file for this run

name: Check links on Academy
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
push:
branches:
- "jamon-chainlink"
defaults:
run:
shell: bash
working-directory: ./tools/chainlink
jobs:
check-links:
runs-on: ubuntu-latest
if: github.repository == 'chainguard-dev/edu'
permissions:
issues: write # opens issues when bad links are found
steps:
- name: 'Github Actions Runner'
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit
- name: 'Checkout default branch to $GITHUB_WORKSPACE dir'
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Install jq
run: |
sudo apt update
sudo apt install -y jq
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Set up Go
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: '^1.20.0'
- name: Run chainlink
run: go run . -contentDir ../../content -hostname edu.chainguard.dev -method GET -checkAll
- name: Find unchecked links
run: |
jq -r '.unchecked []?| {"url":.rawurl, "files":(.files |keys)}' results.json |\
jq -s |\
yq -P > unchecked.json
- name: Find 404 links
run: |
jq '.checked []?| select(.status == 404) | {"url":.rawurl, "files":(.files |keys)}' results.json |\
jq -s |\
yq -P > checked.json
- name: Create issue body
run: |
printf '## Unchecked URLs:\n```\n' > issue-body.txt
cat unchecked.json >> issue-body.txt
printf '```\n\n## 404 URLs\n```\n' >> issue-body.txt
cat checked.json >> issue-body.txt
printf '```\n\n' >> issue-body.txt
printf '## Notes\nAdd any of the unchecked or 404 URLs to `ignore.json` as required' >> issue-body.txt
- name: Create/Update GitHub Issue
env:
GH_TOKEN: ${{ github.token }}
run: |
existing=$(gh issue list --json number,title |\
jq -r '.[] | select(.title == "[chainlink] check links on edu.chainguard.dev") | .number')
if [ -z "${existing}" ]; then
gh issue create \
--title "[chainlink] check links on edu.chainguard.dev" \
--assignee jamonation \
--label automated \
--body-file issue-body.txt
else
gh issue edit $existing --body-file issue-body.txt
fi
- name: Post failure notice to Slack
uses: rtCamp/action-slack-notify@c33737706dea87cd7784c687dadc9adf1be59990 # v2.3.2
if: ${{ failure() }}
env:
SLACK_ICON: http://github.com/chainguard-dev.png?size=48
SLACK_USERNAME: guardian
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: 'alerts-edu'
SLACK_COLOR: '#8E1600'
MSG_MINIMAL: 'true'
SLACK_TITLE: 'Check Links failed - ${{ github.repository }}'
SLACK_MESSAGE: |
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}