Skip to content

Link checker

Link checker #19

Workflow file for this run

name: Link checker
on:
schedule:
- cron: '0 12 1 * *'
workflow_dispatch:
jobs:
build:
name: check-links
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
issues: 'write'
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: 'Authenticate to Google Cloud'
id: 'auth'
uses: 'google-github-actions/auth@v0'
with:
workload_identity_provider: 'projects/855475113448/locations/global/workloadIdentityPools/eto-github/providers/eto-github'
service_account: 'eto-artifact-registry-github@gcp-cset-projects.iam.gserviceaccount.com'
token_format: 'access_token'
- name: 'Log into Artifact Registry'
uses: 'docker/login-action@v1'
with:
registry: us-east1-docker.pkg.dev
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build output files
run: |
cd github-metrics
npm run artifactregistry-login
npm install
npm run build
- name: Check links in built files
id: link_check
run: |
cd github-metrics
find public -name "*.js" -exec grep -Eo "(http|https):\/\/[^]\{\}\"'\\\(\)\> ]+" {} \; | sort -u > linklist.txt
printf '%s\n%s\n%s\n' "# LinkChecker URL list" "# <meta charset=\"UTF-8\">" "$(cat linklist.txt)" > linklist.txt
linkchecker linklist.txt --check-extern --config=.linkcheckerrc --ignore-url="https://.*\.fastly\.net/.*" --ignore-url="https://.*\.mapbox\..*" --ignore-url=".*//a\W.*" --ignore-url="http://(a|x|тест)" --ignore-url="https://arxiv.org/.*" --ignore-url="https://doi.org/.*" --ignore-url="https://docs.google.com/forms/d/e/.*" -o failures > output.txt || true
cat output.txt
echo "num_links=$(wc -l < output.txt | sed 's/^ *//g')" >> $GITHUB_OUTPUT
echo "links<<EOFdelimiter" >> $GITHUB_OUTPUT
echo "$(cat output.txt)" >> $GITHUB_OUTPUT
echo "EOFdelimiter" >> $GITHUB_OUTPUT
- name: Create issue about link checking
if: steps.link_check.outputs.num_links > 0
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUM_LINKS: ${{ steps.link_check.outputs.num_links }}
LINKS: ${{ steps.link_check.outputs.links }}
with:
filename: .github/link-checker-issue-template.md
update_existing: true