Skip to content

Commit

Permalink
✨ Make check update issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CollierCZ committed Mar 2, 2022
1 parent 0c8e5a8 commit 9705429
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,53 @@ jobs:
run: wget --quiet -c "https://github.com/raviqqe/muffet/releases/download/v$MUFFET_VERSION/muffet_${MUFFET_VERSION}_Linux_x86_64.tar.gz" -O - | tar -xz

- name: Check links
env:
URL: https://pr-2189-odiepqq-652soceglkw4u.eu-3.platformsh.site
run: ./muffet --buffer-size=8192 --rate-limit=1 --max-connections-per-host=10 --color=always --header="User-Agent:Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/91.0" -e=console.platform.sh/projects/create-project -e=cloud.orange-business.com -e=developers.cloudflare.com -e=discord.com -e=pptr.dev https://pr-2189-odiepqq-652soceglkw4u.eu-3.platformsh.site
run: ./muffet --json --buffer-size=8192 --rate-limit=1 --max-connections-per-host=10 --color=always --header="User-Agent:Mozilla/5.0 (Windows NT 10.0) Gecko/20100101 Firefox/91.0" -e=console.platform.sh/projects/create-project -e=cloud.orange-business.com -e=developers.cloudflare.com -e=discord.com -e=pptr.dev https://docs.platform.sh > broken_links.json

- name: Create Markdown file of broken links
if: ${{ always() }}
run: |
data=broken_links.json
# Get length of broken links array
eval "$( jq -r '@sh "urls_length=\(.|length)"' "$data" )"
# Check if any links broken
if [ -z "$urls_length" ]; then
":tada: There are no broken links! :tada:" > broken_links.md
else
echo -e "The following pages had broken links to check and possibly fix:\n" > broken_links.md
# Loop through the broken URLs to create items
for (( i = 0; i < urls_length; ++i )); do
unset location
unset broken_links
unset error
# Get the location where the broken link was found
eval "$(
jq -r --argjson i "$i" '
.[$i] |
@sh "location=\(.url)"' "$data"
)"
echo "- $location" >> broken_links.md
# Loop through the broken links
jq -r --argjson i "$i" '.[$i] ' "$data" |
# Get the specific broken link and its error
jq -r '.links[] | (.url, .error)' |
while IFS= read -r url ; do
IFS= read -r error
# Output that as a checklist item
echo " - [ ] $error: $url" >> broken_links.md
done
done
fi
- name: Create issue from Markdown file
id: create-issue
if: ${{ always() }}
uses: peter-evans/create-issue-from-file@v2
with:
title: ":bug: Broken links"
content-filepath: broken_links.md
issue-number: 2213

0 comments on commit 9705429

Please sign in to comment.