Link checker #8
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: 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 web/gui-v2 | |
npm run artifactregistry-login | |
npm install | |
npm run build | |
- name: Check links in built files | |
id: link_check | |
run: | | |
cd web/gui-v2 | |
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://en.wikipedia.org/.*" --ignore-url="https://permid.org/.*" --ignore-url="https://www.crunchbase.com/.*" --ignore-url="https://www.google.com/.*" --ignore-url="https://www.grid.ac/.*" --ignore-url="https://www.linkedin.com/.*" --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 |