Skip to content

Commit

Permalink
Merge pull request #90 from digitalservicebund/tech/caching_improvements
Browse files Browse the repository at this point in the history
Pipeline caching improvements
  • Loading branch information
Deeds67 authored Jan 9, 2025
2 parents 5899f40 + 47ad813 commit 218fad2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,18 @@ jobs:
path: tests/a11y/playwright-report

- name: Cache Docker image
id: cache-docker-image
uses: actions/cache@v4
with:
path: |
/tmp/.docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
restore-keys:
| # If the exact cache can't be found, a partial match will still be useful here, since it will allow docker to reuse the layers from the cached image that are still valid.
${{ runner.os }}-docker-

- name: Build and cache image from Dockerfile
if: steps.cache-docker-image.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/.docker-cache/${{ env.IMAGE_NAME }}
docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} . --build-arg COMMIT_SHA=${{ github.sha }}
Expand Down Expand Up @@ -169,27 +172,24 @@ jobs:
path: |
/tmp/.docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-

- name: Load cached Docker image
id: load-docker-image
run: |
echo "IMAGE_NAME=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
echo "IMAGE_TAG=${{ github.sha }}" >> $GITHUB_ENV
IMAGE_PATH="/tmp/.docker-cache/${{ env.IMAGE_NAME }}_${{ github.sha }}.tar"
if docker load -i $IMAGE_PATH; then
echo "cache-hit=true" >> $GITHUB_ENV
echo "::set-output name=cache-hit::true"
echo "Docker image loaded from: $IMAGE_PATH"
echo "docker-image-load-successful=true" >> $GITHUB_ENV
echo "::set-output name=docker-image-load-successful::true"
echo "Docker image loaded from cache: $IMAGE_PATH"
else
echo "cache-hit=false" >> $GITHUB_ENV
echo "::set-output name=cache-hit::false"
echo "docker-image-load-successful=false" >> $GITHUB_ENV
echo "::set-output name=docker-image-load-successful::false"
echo "Docker image not found in cache: $IMAGE_PATH"
fi
- name: Build image from Dockerfile in case no cached image was found
if: steps.load-docker-image.outputs.cache-hit != 'true'
if: steps.load-docker-image.outputs.docker-image-load-successful != 'true'
run: |
docker build -t ${{ env.IMAGE_NAME }}:${{ github.sha }} . --build-arg COMMIT_SHA=${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fileignoreconfig:
- filename: SECURITY.md
checksum: b1743150cdd537be3a66f5308f887d130f0f320ab21628b63713808090a84e3f
- filename: .github/workflows/pipeline.yml
checksum: 32835b1ea7c77a0b86eb5dff6a869d4a5c63e215257157e8de66a7b7acea6286
checksum: dc40f4db09eb6dda55c99c6b9a3a96ef4bf4591f4fbbae14e7991385ab9d114f
- filename: .env.example
checksum: e4f39c1718c11d16be854b2ff85c9bfb1d6ea9d5d1fafa3945515b5b458f0dcc
- filename: app/config/config.server.ts
Expand Down

0 comments on commit 218fad2

Please sign in to comment.