name: 'link-verifier' description: 'Verify links (URLs, anchors, and relative path hyperlinks)' inputs: path: description: 'Path to repository folder to run link verification on.' required: false default: ./ exclude-dirs: description: 'Comma-separated list of directory names to ignore. (Eg. cmock, cmbc)' required: false default: '' include-file-types: description: 'Comma-separated list of file type patters in repository to test. (Eg .c, .h)' required: false default: '.c .h .dox' allowlist-file: description: 'Path to file containing allowlist of URLs.' required: false default: '' user-agent: description: 'User agent string to use when making http requests.' required: false default: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.84 Safari/537.36' runs: using: "composite" steps: - name: Install pandoc run: | wget https://github.com/jgm/pandoc/releases/download/2.11/pandoc-2.11-1-amd64.deb -O pandoc.deb sudo dpkg -i pandoc.deb rm pandoc.deb sudo apt install debsums sudo debsums pandoc shell: bash - name: Install ghcurl run: | sudo type -p curl >/dev/null || sudo apt install curl -y shell: bash - name: Install gh run: | curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null sudo apt update sudo apt install -y gh shell: bash - name: Install python dependencies run: | sudo apt-get install -y python3-setuptools python3-pip python3 -m pip install -r $GITHUB_ACTION_PATH/requirements.txt shell: bash - name: Run link verifier script run: | args="--verbose --test-markdown" if [ -n "${{ inputs.exclude-dirs }}" ]; then dirs="${{ inputs.exclude-dirs }}" dirs="${dirs//,/ }" args+=" --exclude-dirs ${dirs}" fi if [ -n "${{ inputs.include-file-types }}" ]; then file_types="${{ inputs.include-file-types }}" file_types="${file_types//,/ }" args+=" --include-file-types ${file_types}" fi if [ -n "${{ inputs.allowlist-file }}" ]; then allowlist_file="${{ inputs.allowlist-file }}" allowlist_file="${allowlist_file//,/ }" args+=" --allowlist-file ${allowlist_file}" fi echo "Running verify-links.py ${args} --user-agent \"${{ inputs.user-agent }}\"" if python3 ${GITHUB_ACTION_PATH}/verify-links.py ${args} --user-agent "${{ inputs.user-agent }}"; then exit 0 else exit 1 fi shell: bash