diff --git a/.github/workflows/check_links.yml b/.github/workflows/check_links.yml
index 5d2e1f1..7d845fe 100644
--- a/.github/workflows/check_links.yml
+++ b/.github/workflows/check_links.yml
@@ -23,8 +23,6 @@ jobs:
name: Check image links
runs-on: ubuntu-latest
- env:
- lychee_args: '--no-progress --require-https --cache --max-cache-age 8h --exclude http://www.w3.org'
steps:
- name: Checkout
@@ -39,13 +37,62 @@ jobs:
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- # Extract and check URLs directly from token files
+ # Extract picture URLs from tokens.xml
+ - name: Extract URLs
+ id: tokens_pic_urls
+ uses: lycheeverse/lychee-action@v2
+ with:
+ args: --dump --exclude www.w3.org -- tokens.xml
+ output: lychee/url_list.md
+ jobSummary: false
+
+ # Print output
+ - name: Print List of URLs
+ run: cat ./lychee/url_list.md
+
+ # Check dumped URLs
- name: Check token art URLs
+ if: steps.tokens_pic_urls.outcome == 'success'
uses: lycheeverse/lychee-action@v2
with:
- args: '${{env.lychee_args}} -- tokens.xml'
+ args: --no-progress --require-https --cache --max-cache-age 8h -- './lychee/url_list.md'
jobSummary: true
+ # # Fallback if dump not working (TODO)
+ # - name: Check token art URLs
+ # if: steps.tokens_pic_urls.outcome == 'success'
+ # uses: lycheeverse/lychee-action@v2
+ # with:
+ # args: '${{env.lychee_args}} -- ./lychee/out.md'
+ # jobSummary: true
+
+ # List some helpful stats on missing pictures
+ - name: List missing image link counts
+ shell: bash
+ run: |
+ echo "❌ **Missing Image Links (master branch)**" >> $GITHUB_STEP_SUMMARY
+ echo "Token with missing \`set\` element: [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml)" >> $GITHUB_STEP_SUMMARY
+ echo "Missing picURL attribute (\`\`): [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml)" >> $GITHUB_STEP_SUMMARY
+ echo "Empty picURL value (\`\`): [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml)" >> $GITHUB_STEP_SUMMARY
+
+ # Analyse extracted links (1/2)
+ - name: List duplicated image links
+ if: steps.tokens_pic_urls.outcome == 'success'
+ shell: bash
+ # Remove empty lines | trim trailing integers (Scryfall) | sort | count and list duplicates
+ run: |
+ echo "🪞 **Duplicated Image Links**" >> $GITHUB_STEP_SUMMARY
+ grep . lychee/out.md | sed 's/\.jpg?.*/.jpg/' | sort | uniq -cd >> $GITHUB_STEP_SUMMARY
+
+ # Analyse extracted links (2/2)
+ - name: List image hosting sources
+ if: steps.tokens_pic_urls.outcome == 'success'
+ shell: bash
+ # Extract 3rd field (domain name) | remove empty lines | sort | count duplicates and list with numbers | sort descending
+ run: |
+ echo "📶 **Image Hosting Statistics**" >> $GITHUB_STEP_SUMMARY
+ awk -F/ '{print $3}' lychee/out.md | grep . | sort | uniq -c | sort -nr >> $GITHUB_STEP_SUMMARY
+
# Always save cache
- name: Save lychee cache
uses: actions/cache/save@v4