mirror of
https://github.com/Cockatrice/Magic-Token.git
synced 2026-03-22 01:54:39 -05:00
Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/cache dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
105 lines
4.3 KiB
YAML
105 lines
4.3 KiB
YAML
name: Picture Health
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths:
|
|
- '.github/workflows/check_links.yml'
|
|
- '**.xml'
|
|
pull_request:
|
|
branches: [ master ]
|
|
paths:
|
|
- '.github/workflows/check_links.yml'
|
|
- '**.xml'
|
|
pull_request_review:
|
|
types: [ submitted ]
|
|
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
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
|
|
# Restore cache
|
|
- name: Restore lychee cache
|
|
id: restore-cache
|
|
uses: actions/cache/restore@v5
|
|
with:
|
|
path: .lycheecache
|
|
key: cache-lychee-${{ github.sha }}
|
|
restore-keys: cache-lychee-
|
|
|
|
# Extract picture URLs from tokens.xml
|
|
- name: Extract URLs
|
|
id: tokens_pic_urls
|
|
uses: lycheeverse/lychee-action@v2
|
|
with:
|
|
args: --dump -- tokens.xml
|
|
output: url_list.md
|
|
jobSummary: false
|
|
|
|
# Check dumped URLs
|
|
- name: Check token art URLs
|
|
if: steps.tokens_pic_urls.outcome == 'success'
|
|
uses: lycheeverse/lychee-action@v2
|
|
with:
|
|
args: --no-progress --require-https --cache --max-cache-age 8h -- url_list.md
|
|
jobSummary: true
|
|
|
|
# List helpful stats on missing pictures
|
|
- name: List missing image link counts
|
|
shell: bash
|
|
run: |
|
|
{
|
|
echo "❌ **Missing Image Links (<kbd>master</kbd> Branch)**"
|
|
echo "| Count | Description |"
|
|
echo "|------:|:------------|"
|
|
echo "| [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml) | Tokens with missing \`set\` element |"
|
|
echo "| [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml) | Set elements with missing picURL attribute (\`<set>\`) |"
|
|
echo "| [](https://raw.githubusercontent.com/Cockatrice/Magic-Token/master/tokens.xml) | Set elements with empty picURL value (\`<set picURL=\"\">\`) |"
|
|
} >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Analyse extracted links (1/2)
|
|
- name: List duplicated image links
|
|
if: steps.tokens_pic_urls.outcome == 'success'
|
|
shell: bash
|
|
run: |
|
|
{
|
|
echo "🪞 **Duplicated Image Links**"
|
|
echo "| Count | Image URL |"
|
|
echo "|------:|:----------|"
|
|
# Remove empty lines | trim trailing integers (Scryfall) | sort | count and list only duplicates with numbers | sort descending | print md table
|
|
grep . url_list.md | sed 's/\.jpg?.*/.jpg/' | sort | uniq -cd | sort -nr | awk '{printf "| %5s | %s |\n", $1, $2}'
|
|
} >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Analyse extracted links (2/2)
|
|
- name: List image hosting sources
|
|
if: steps.tokens_pic_urls.outcome == 'success'
|
|
shell: bash
|
|
run: |
|
|
{
|
|
echo "📶 **Image Hosting Statistics**"
|
|
echo "| Count | Domain |"
|
|
echo "|------:|:-------|"
|
|
# Extract 3rd field (domain name) | remove empty lines | sort | count and list with numbers | sort descending | print md table
|
|
awk -F/ '{print $3}' url_list.md | grep . | sort | uniq -c | sort -nr | awk '{printf "| %5s | %s |\n", $1, $2}'
|
|
} >> $GITHUB_STEP_SUMMARY
|
|
|
|
# Always save cache
|
|
- name: Save lychee cache
|
|
uses: actions/cache/save@v5
|
|
if: always()
|
|
with:
|
|
path: .lycheecache
|
|
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|