Skip to content

Commit

Permalink
ci: Add Docker cache (#34)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax committed Aug 2, 2024
1 parent 17adc0e commit f32578c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/verify-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- run: |
TEMPDIR=/cache/docker
sudo mkdir -p "${TEMPDIR}"
sudo mount -t tmpfs none "$TEMPDIR"
sudo chown runner "$TEMPDIR"
- uses: actions/cache/restore@v4
id: cache
with:
path: /cache/docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile*') }}
- run: |
sudo systemctl stop docker docker.socket
sudo rm -rf /var/lib/docker/{*,.*}
TEMPDIR=/cache/docker
zstd --stdout -d "${TEMPDIR}/docker.tar.zst" | sudo tar --warning=no-timestamp -xf - -C /var/lib/docker
sudo umount "$TEMPDIR"
sudo systemctl start docker
if: steps.cache.outputs.cache-hit == 'true'
- run: |
sudo systemctl stop docker docker.socket
sudo rm -rf /var/lib/docker/{*,.*}
sudo systemctl start docker
if: steps.cache.outputs.cache-hit != 'true'
- run: |
sudo apt-get update
sudo apt-get -qq install -y --no-install-recommends expect gettext yq whois
Expand All @@ -32,3 +56,15 @@ jobs:
--host_action_env="DEV_CONTAINER_ID=${DEV_CONTAINER_ID}" \
--sandbox_writable_path="${HOME}/.docker/" \
--sandbox_writable_path=$HOME :verify_examples
- run: |
sudo systemctl stop docker docker.socket
TEMPDIR=/cache/docker
sudo tar cf - -C /var/lib/docker . | zstd - -q -T0 -o "${TEMPDIR}/docker.tar.zst"
ls -alh "${TEMPDIR}/docker.tar.zst"
if: steps.cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request'
- uses: actions/cache/save@v4
if: steps.cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request'
with:
path: /cache/docker
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile*') }}

0 comments on commit f32578c

Please sign in to comment.