From 5b76cbfad0aff0d443bd605dc597316e07ad14d6 Mon Sep 17 00:00:00 2001 From: Rickey Fehr Date: Sun, 14 Sep 2025 13:25:57 -0700 Subject: [PATCH] Add cache for docker compose container --- .github/workflows/build_ci_workflow.yml | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_ci_workflow.yml b/.github/workflows/build_ci_workflow.yml index 45b2760..cf270ee 100644 --- a/.github/workflows/build_ci_workflow.yml +++ b/.github/workflows/build_ci_workflow.yml @@ -8,15 +8,44 @@ on: branches: - main workflow_dispatch: + inputs: + clear_cache: + description: 'Clear docker cache before running' + type: boolean + default: false jobs: build: runs-on: ubuntu-latest - steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Get docker image cache + uses: actions/cache@v4 + with: + path: /tmp/docker-cache + key: docker-images-${{ hashFiles('docker-compose.yml') }} + + - name: Clear docker cache (if requested) + if: github.event.inputs.clear_cache == 'true' + run: | + echo "Clearing Docker cache..." + rm -rf /tmp/docker-cache + echo "Docker cache cleared" + + - name: Load or pull images + run: | + if [ -f /tmp/docker-cache/balatro.tar ]; then + echo "Loading Image" + docker load -i /tmp/docker-cache/balatro.tar + else + echo "Pulling Image" + docker compose pull balatro + mkdir -p /tmp/docker-cache + docker save $(docker compose config | grep image: | awk '{print $2}') -o /tmp/docker-cache/balatro.tar + fi + - name: Export UID/GID for Compose run: | echo "UID=$(id -u)" >> "$GITHUB_ENV" @@ -24,7 +53,3 @@ jobs: - name: Build the project run: docker compose -f docker-compose.yml run --rm balatro sh -c "make -j$(nproc)" - - - name: Compose down - if: always() - run: docker compose -f docker-compose.yml down -v || true