Skip to content

CI: Show useful data about token URLs #407

CI: Show useful data about token URLs

CI: Show useful data about token URLs #407

Workflow file for this run

name: Picture Health
on:
pull_request:
# Default events are opened, synchronized or reopened
workflow_dispatch:
schedule:
# Runs at the start of each month (UTC)
- cron: '0 0 1 * *'
jobs:
check_urls:
# Do not run the scheduled workflow on forks
if: ( github.event_name != 'schedule' || github.repository_owner == 'Cockatrice' )
name: Check image links
runs-on: ubuntu-latest
env:
lychee_args: '--no-progress --require-https --cache --max-cache-age 1h --exclude http://www.w3.org'
steps:
- name: Checkout
uses: actions/checkout@v3
# Restore cache
- name: Restore lychee cache
id: restore-cache
uses: actions/cache/restore@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Extract picture URLs from tokens.xml
id: tokens_pic_urls
uses: lycheeverse/lychee-action@v1
with:
args: '--dump --exclude www.w3.org -- tokens.xml'
output: lychee/out.md
fail: true
jobSummary: false
- name: Print dumped output file
shell: bash
run: cat lychee/out.md
- name: List duplicated image links
if: steps.tokens_pic_urls.outcome == 'success'
shell: bash
# Remove blank lines | trim trailing integers (Scryfall) | sort | count and list duplicates
run: |
grep . lychee/out.md | sed 's/\.jpg?.*/.jpg/' | sort | uniq -cd >> $GITHUB_STEP_SUMMARY
- name: List image hosting sources
if: steps.tokens_pic_urls.outcome == 'success'
shell: bash
# Extract domains from URLs | remove blank lines | sort | count and list | sort descending
run: |
awk -F/ '{print $3}' lychee/out.md | grep . | sort | uniq -c | sort -nr >> $GITHUB_STEP_SUMMARY
# Check already extracted URLs from tokens.xml
- name: Check dumped URLs from tokens.xml
uses: lycheeverse/lychee-action@v1
if: steps.tokens_pic_urls.outcome == 'success'
with:
args: --no-progress --require-https --cache --max-cache-age 1h 'lychee/out.md'
fail: true
jobSummary: true
# Extract and check URLs directly from token files
- name: Check token art URLs
uses: lycheeverse/lychee-action@v1
with:
args: '${{env.lychee_args}} -- tokens.xml'
fail: true
jobSummary: true
# Always save cache
- name: Save lychee cache
uses: actions/cache/save@v3
if: always()
with:
path: .lycheecache
key: ${{ steps.restore-cache.outputs.cache-primary-key }}