111 lines
4.1 KiB
YAML
111 lines
4.1 KiB
YAML
name: 'Link Checker: On PR'
|
|
|
|
# **What it does**: Renders the content of every page and check all internal links on PR.
|
|
# **Why we have it**: To make sure all links connect correctly on changed files.
|
|
# **Who does it impact**: Docs content.
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
merge_group:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
# TODO: Uncomment if we uncomment below
|
|
# Needed for the 'trilom/file-changes-action' action
|
|
# pull-requests: read
|
|
|
|
# This allows a subsequently queued workflow run to interrupt previous runs
|
|
concurrency:
|
|
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check-links:
|
|
runs-on: ${{ fromJSON('["ubuntu-latest", "ubuntu-20.04-xl"]')[github.repository == 'github/docs-internal'] }}
|
|
if: github.repository == 'github/docs-internal' || github.repository == 'github/docs'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
|
|
|
|
- name: Setup node
|
|
uses: actions/setup-node@17f8bd926464a1afa4c6a11669539e9c1ba77048
|
|
with:
|
|
node-version: '16.15.0'
|
|
cache: npm
|
|
|
|
- name: Install
|
|
run: npm ci
|
|
|
|
- name: Figure out which docs-early-access branch to checkout, if internal repo
|
|
if: ${{ github.repository == 'github/docs-internal' }}
|
|
id: check-early-access
|
|
env:
|
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
run: node .github/actions-scripts/what-docs-early-access-branch.js
|
|
|
|
- name: Check out docs-early-access too, if internal repo
|
|
if: ${{ github.repository == 'github/docs-internal' }}
|
|
uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748
|
|
with:
|
|
repository: github/docs-early-access
|
|
token: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
path: docs-early-access
|
|
ref: ${{ steps.check-early-access.outputs.branch }}
|
|
|
|
- name: Merge docs-early-access repo's folders
|
|
if: ${{ github.repository == 'github/docs-internal' }}
|
|
run: .github/actions-scripts/merge-early-access.sh
|
|
|
|
# TODO: When we want to fix redirects on changed files we can uncomment everything below
|
|
# Creates file "${{ env.HOME }}/files.json", among others
|
|
# - name: Gather files changed
|
|
# if: github.event_name != 'merge_group'
|
|
# id: file_changes
|
|
# uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
|
|
# with:
|
|
# fileOutput: 'json'
|
|
|
|
# For verification
|
|
# - name: Show files changed (debug)
|
|
# if: github.event_name != 'merge_group'
|
|
# run: cat $HOME/files.json
|
|
|
|
# - name: Link check changed pages (external links only)
|
|
# if: github.event_name != 'merge_group'
|
|
# id: changed_links
|
|
# env:
|
|
# LEVEL: 'warning'
|
|
# FILES_CHANGED: ${{ steps.file_changes.outputs.files }}
|
|
# ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
# GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }}
|
|
# SHOULD_COMMENT: true
|
|
# CREATE_REPORT: false
|
|
# run: node .github/actions/rendered-content-link-checker.js
|
|
|
|
- name: Link check all pages (internal links only)
|
|
id: all_links
|
|
env:
|
|
LEVEL: 'critical'
|
|
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_FR }}
|
|
SHOULD_COMMENT: ${{ secrets.DOCS_BOT_FR != '' }}
|
|
CHECK_EXTERNAL_LINKS: false
|
|
CREATE_REPORT: false
|
|
run: node .github/actions/rendered-content-link-checker.js
|
|
|
|
- name: Upload artifact(s)
|
|
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8
|
|
with:
|
|
name: artifacts
|
|
path: ./artifacts
|
|
|
|
- name: Fail if either check has broken links in its level
|
|
if: ${{ steps.changed_links.outputs.has_flaws_at_level == 'true' || steps.all_links.outputs.has_flaws_at_level == 'true' }}
|
|
run: |
|
|
exit 1
|