Skip to content

Check links on Academy #408

Check links on Academy

Check links on Academy #408

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
permissions:
issues: write # opens issues when bad links are found
steps:
- name: 'Github Actions Runner'
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- name: 'Checkout default branch to $GITHUB_WORKSPACE dir'
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- 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@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # actions/setup-go@v4
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