mirror of
https://github.com/mwisnowski/mtg_python_deckbuilder.git
synced 2025-12-29 21:58:50 +01:00
feat: optimize cache workflow with orphan branch and age check
- Create/use orphan branch 'similarity-cache-data' for cache distribution - Add age check to dockerhub-publish: only rebuild if cache >7 days old - Use git add -f to force-add cache files (keeps .gitignore clean) - Weekly scheduled builds will keep cache fresh automatically This avoids rebuilding cache on every Docker publish while ensuring cache is always reasonably fresh (<7 days old).
This commit is contained in:
parent
b26057f68d
commit
86752b351b
3 changed files with 62 additions and 8 deletions
28
.github/workflows/build-similarity-cache.yml
vendored
28
.github/workflows/build-similarity-cache.yml
vendored
|
|
@ -145,12 +145,30 @@ jobs:
|
|||
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
|
||||
# Switch to or create dedicated cache branch
|
||||
git checkout -b similarity-cache-data || git checkout similarity-cache-data
|
||||
# Fetch all branches
|
||||
git fetch origin
|
||||
|
||||
# Add only the similarity cache files (not all_cards.parquet)
|
||||
git add card_files/similarity_cache.parquet
|
||||
git add card_files/similarity_cache_metadata.json
|
||||
# Try to checkout existing branch, or create new orphan branch
|
||||
if git ls-remote --heads origin similarity-cache-data | grep similarity-cache-data; then
|
||||
echo "Checking out existing similarity-cache-data branch..."
|
||||
git checkout similarity-cache-data
|
||||
else
|
||||
echo "Creating new orphan branch similarity-cache-data..."
|
||||
git checkout --orphan similarity-cache-data
|
||||
git rm -rf . || true
|
||||
# Create minimal README for the branch
|
||||
echo "# Similarity Cache Data" > README.md
|
||||
echo "This branch contains pre-built similarity cache files for the MTG Deckbuilder." >> README.md
|
||||
echo "Updated automatically by GitHub Actions." >> README.md
|
||||
fi
|
||||
|
||||
# Ensure card_files directory exists
|
||||
mkdir -p card_files
|
||||
|
||||
# Add only the similarity cache files (use -f to override .gitignore)
|
||||
git add -f card_files/similarity_cache.parquet
|
||||
git add -f card_files/similarity_cache_metadata.json
|
||||
git add README.md 2>/dev/null || true
|
||||
|
||||
# Check if there are changes to commit
|
||||
if git diff --staged --quiet; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue