|
| 1 | +name: 'Tools data cache' |
| 2 | +description: 'find latest release; construct cache key; fetch/build cache' |
| 3 | + |
| 4 | +inputs: |
| 5 | + failIfMissing: |
| 6 | + description: "Should the job fail if missing" |
| 7 | + default: "false" |
| 8 | + |
| 9 | +outputs: |
| 10 | + cache_key: |
| 11 | + description: Cache retrieval key |
| 12 | + value: ${{ steps.test_data.outputs.cache_key }} |
| 13 | + |
| 14 | +runs: |
| 15 | + using: "composite" |
| 16 | + steps: |
| 17 | + |
| 18 | + - name: 5eTools release cache key |
| 19 | + id: test_data |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + LATEST_5E_VERSION=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/5etools-mirror-3/5etools-src/releases/latest | jq -r .tag_name) |
| 23 | + LATEST_PF2E_VERSION=$(curl -sLH 'Accept: application/json' https://api.github.com/repos/Pf2eToolsOrg/Pf2eTools/releases/latest | jq -r .tag_name) |
| 24 | +
|
| 25 | + LATEST_VERSION=5e.${LATEST_5E_VERSION}-Pf2e.${LATEST_PF2E_VERSION} |
| 26 | + PREFIX="TestData-" |
| 27 | + KEY=${PREFIX}${LATEST_VERSION} |
| 28 | +
|
| 29 | + echo "🔹 Use 5eTools $LATEST_5E_VERSION and Pf2eTools $LATEST_PF2E_VERSION" |
| 30 | + echo "cache_key_prefix=${PREFIX}" >> $GITHUB_OUTPUT |
| 31 | + echo "cache_key=${KEY}" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + echo "version_5e=${LATEST_5E_VERSION}" >> $GITHUB_OUTPUT |
| 34 | + echo "version_pf2e=${LATEST_PF2E_VERSION}" >> $GITHUB_OUTPUT |
| 35 | +
|
| 36 | + - name: Check Cache Data |
| 37 | + id: test_data_check |
| 38 | + uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 |
| 39 | + with: |
| 40 | + path: sources |
| 41 | + key: ${{ steps.test_data.outputs.cache_key }} |
| 42 | + fail-on-cache-miss: ${{ inputs.failIfMissing == 'true' }} |
| 43 | + enableCrossOsArchive: true |
| 44 | + |
| 45 | + - name: Download Test Data |
| 46 | + id: test-data-download |
| 47 | + if: steps.test_data_check.outputs.cache-hit != 'true' |
| 48 | + shell: bash |
| 49 | + env: |
| 50 | + LATEST_5E_VERSION: ${{ steps.test_data.outputs.version_5e }} |
| 51 | + LATEST_PF2E_VERSION: ${{ steps.test_data.outputs.version_pf2e }} |
| 52 | + GITHUB_TOKEN: ${{ github.token }} |
| 53 | + run: | |
| 54 | + echo "🔹 Download 5e $LATEST_5E_VERSION" |
| 55 | +
|
| 56 | + # sparse clone of src |
| 57 | + mkdir -p sources/5etools-src |
| 58 | + git clone --quiet --depth=1 -b ${LATEST_5E_VERSION} \ |
| 59 | + -c advice.detachedHead=false \ |
| 60 | + --no-checkout \ |
| 61 | + https://github.com/5etools-mirror-3/5etools-src.git sources/5etools-src |
| 62 | + pushd sources/5etools-src |
| 63 | + git sparse-checkout init |
| 64 | + git sparse-checkout set data |
| 65 | + git checkout ${LATEST_5E_VERSION} |
| 66 | + rm -rf .git |
| 67 | + rm -f *.png |
| 68 | + rm -f *.html |
| 69 | + rm -f *.zip |
| 70 | + popd |
| 71 | +
|
| 72 | + mkdir -p sources/5etools-img |
| 73 | + gh release download ${LATEST_5E_VERSION} -D sources/5etools-img -R 5etools-mirror-3/5etools-img |
| 74 | + pushd sources/5etools-img |
| 75 | + zip -FF img-${LATEST_5E_VERSION}.zip --out fixed.zip |
| 76 | + unzip -q fixed.zip |
| 77 | + rm *.z* |
| 78 | + du -sh . |
| 79 | + # replace all images w/ empty files. We don't care about image content for test purposes |
| 80 | + find img -type f | while read FILE; do echo > "$FILE"; done |
| 81 | + mv img/* . |
| 82 | + du -sh . |
| 83 | + popd |
| 84 | +
|
| 85 | + echo "🔹 5eTools: Download Homebrew" |
| 86 | +
|
| 87 | + # Don't grab all of homebrew. Too big |
| 88 | + mkdir -p sources/5e-homebrew/adventure |
| 89 | + mkdir -p sources/5e-homebrew/background |
| 90 | + mkdir -p sources/5e-homebrew/book |
| 91 | + mkdir -p sources/5e-homebrew/class |
| 92 | + mkdir -p sources/5e-homebrew/collection |
| 93 | + mkdir -p sources/5e-homebrew/creature |
| 94 | + mkdir -p sources/5e-homebrew/deity |
| 95 | + mkdir -p sources/5e-homebrew/optionalfeature |
| 96 | + mkdir -p sources/5e-homebrew/race |
| 97 | + mkdir -p sources/5e-homebrew/subclass |
| 98 | +
|
| 99 | + paths=( |
| 100 | + "collection/MCDM Productions; Strongholds and Followers.json" |
| 101 | + "adventure/Anthony Joyce; The Blood Hunter Adventure.json" |
| 102 | + "adventure/Arcanum Worlds; Odyssey of the Dragonlords.json" |
| 103 | + "adventure/JVC Parry; Call from the Deep.json" |
| 104 | + "adventure/Kobold Press; Book of Lairs.json" |
| 105 | + "background/D&D Wiki; Featured Quality Backgrounds.json" |
| 106 | + "book/Ghostfire Gaming; Grim Hollow Campaign Guide.json" |
| 107 | + "book/Ghostfire Gaming; Stibbles Codex of Companions.json" |
| 108 | + "book/MCDM Productions; Arcadia Issue 3.json" |
| 109 | + "class/D&D Wiki; Swashbuckler.json" |
| 110 | + "class/Foxfire94; Vampire.json" |
| 111 | + "class/KibblesTasty; Inventor.json" |
| 112 | + "class/LaserLlama; Alternate Barbarian.json" |
| 113 | + "class/Matthew Mercer; Blood Hunter (2022).json" |
| 114 | + "class/badooga; Badooga's Psion.json" |
| 115 | + "collection/Arcana Games; Arkadia.json" |
| 116 | + "collection/Ghostfire Gaming; Grim Hollow - The Monster Grimoire.json" |
| 117 | + "collection/Jasmine Yang; Hamund's Herbalism Handbook.json" |
| 118 | + "collection/Keith Baker; Exploring Eberron.json" |
| 119 | + "collection/Kobold Press; Deep Magic 14 Elemental Magic.json" |
| 120 | + "collection/Kobold Press; Deep Magic.json" |
| 121 | + "collection/Loot Tavern; Heliana's Guide To Monster Hunting.json" |
| 122 | + "collection/MCDM Productions; The Talent and Psionics Open Playtest Round 2.json" |
| 123 | + "collection/Mage Hand Press; Valda's Spire of Secrets.json" |
| 124 | + "creature/Dragonix; Monster Manual Expanded III.json" |
| 125 | + "creature/Kobold Press; Creature Codex.json" |
| 126 | + "creature/Kobold Press; Tome of Beasts 2.json" |
| 127 | + "creature/Kobold Press; Tome of Beasts.json" |
| 128 | + "creature/MCDM Productions; Flee, Mortals! preview.json" |
| 129 | + "creature/MCDM Productions; Flee, Mortals!.json" |
| 130 | + "creature/Nerzugal Role-Playing; Nerzugal's Extended Bestiary.json" |
| 131 | + "deity/Frog God Games; The Lost Lands.json" |
| 132 | + "optionalfeature/laserllama; Laserllama's Exploit Compendium.json" |
| 133 | + "race/Middle Finger of Vecna; Archon.json" |
| 134 | + "subclass/LaserLlama; Druid Circles.json" |
| 135 | + ) |
| 136 | +
|
| 137 | + for i in "${paths[@]}"; do |
| 138 | + echo "$i" |
| 139 | + url=${i// /%20} |
| 140 | + echo "$url" |
| 141 | + curl -s -S -L -o "sources/5e-homebrew/$i" "https://raw.githubusercontent.com/TheGiddyLimit/homebrew/refs/heads/master/${url}" |
| 142 | + done |
| 143 | +
|
| 144 | + echo "🔹 5eTools: Download Unearthed Arcana" |
| 145 | +
|
| 146 | + # Don't grab all of unearthed arcana |
| 147 | + mkdir -p sources/5e-unearthed-arcana/collection |
| 148 | +
|
| 149 | + paths=( |
| 150 | + "collection/Unearthed Arcana - Downtime.json" |
| 151 | + "collection/Unearthed Arcana - Encounter Building.json" |
| 152 | + "collection/Unearthed Arcana - Into the Wild.json" |
| 153 | + "collection/Unearthed Arcana - Quick Characters.json" |
| 154 | + "collection/Unearthed Arcana - Traps Revisited.json" |
| 155 | + "collection/Unearthed Arcana - When Armies Clash.json" |
| 156 | + "collection/Unearthed Arcana 2022 - Character Origins.json" |
| 157 | + "collection/Unearthed Arcana 2022 - Expert Classes.json" |
| 158 | + "collection/Unearthed Arcana 2022 - The Cleric and Revised Species.json" |
| 159 | + "collection/Unearthed Arcana 2023 - Bastions and Cantrips.json" |
| 160 | + "collection/Unearthed Arcana 2023 - Druid & Paladin.json" |
| 161 | + "collection/Unearthed Arcana 2023 - Player's Handbook Playtest 5.json" |
| 162 | + "collection/Unearthed Arcana 2023 - Player's Handbook Playtest 6.json" |
| 163 | + "collection/Unearthed Arcana 2023 - Player's Handbook Playtest 7.json" |
| 164 | + ) |
| 165 | +
|
| 166 | + for i in "${paths[@]}"; do |
| 167 | + echo "$i" |
| 168 | + url=${i// /%20} |
| 169 | + echo "$url" |
| 170 | + curl -s -S -L -o "sources/5e-unearthed-arcana/$i" "https://raw.githubusercontent.com/TheGiddyLimit/unearthed-arcana/refs/heads/master/${url}" |
| 171 | + done |
| 172 | +
|
| 173 | + echo "🔹 Pf2eTools Download ${LATEST_PF2E_VERSION}" |
| 174 | +
|
| 175 | + # sparse clone of src |
| 176 | + mkdir -p sources/Pf2eTools |
| 177 | + git clone --quiet --depth=1 -b ${LATEST_PF2E_VERSION} \ |
| 178 | + -c advice.detachedHead=false \ |
| 179 | + --no-checkout \ |
| 180 | + https://github.com/Pf2eToolsOrg/Pf2eTools.git sources/Pf2eTools |
| 181 | + pushd sources/Pf2eTools |
| 182 | + git sparse-checkout init |
| 183 | + git sparse-checkout set data img |
| 184 | + git checkout ${LATEST_VERSION} |
| 185 | + rm -rf .git |
| 186 | + rm -f *.png |
| 187 | + rm -f *.html |
| 188 | + rm -f *.xml |
| 189 | + find img -type f | while read FILE; do echo > "$FILE"; done |
| 190 | + popd |
| 191 | +
|
| 192 | + ls -al sources |
| 193 | + du -sh sources |
| 194 | +
|
| 195 | + - name: Always Save Cache |
| 196 | + id: test_data_save |
| 197 | + if: always() && steps.test_data_check.outputs.cache-hit != 'true' |
| 198 | + uses: actions/cache/save@v4 |
| 199 | + with: |
| 200 | + key: ${{ steps.test_data.outputs.cache_key }} |
| 201 | + path: sources |
0 commit comments