Skip to content

Commit

Permalink
ci: Enable apt caching for container builds
Browse files Browse the repository at this point in the history
The Dockerfile is already prepared and works locally. Now also make use
of that on github. We cache per matrix job to avoid mutual overwriting.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed Mar 6, 2024
1 parent e94ea5e commit 3cf1f29
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/actions/docker-init/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ inputs:
required: true
deploy-token:
required: true
cache-key:
required: true

runs:
using: composite
Expand Down Expand Up @@ -35,3 +37,27 @@ runs:
run: |
git clone . /home/runner/kas-clone
shell: bash
- name: Cache var-cache-apt
id: cache-var-cache-apt
uses: actions/cache@v4
with:
path: var-cache-apt
key: var-cache-apt-${{ env.DEBIAN_TAG }}-${{ inputs.cache-key }}
- name: Cache var-lib-apt
id: cache-var-lib-apt
uses: actions/cache@v4
with:
path: var-lib-apt
key: var-lib-apt-${{ env.DEBIAN_TAG }}-${{ inputs.cache-key }}
- name: Inject var-cache-apt into docker
uses: reproducible-containers/[email protected]
with:
cache-source: var-cache-apt
cache-target: /var/cache/apt
skip-extraction: ${{ steps.cache-var-cache-apt.outputs.cache-hit }}
- name: Inject var-lib-apt into docker
uses: reproducible-containers/[email protected]
with:
cache-source: var-lib-apt
cache-target: /var/lib/apt
skip-extraction: ${{ steps.cache-var-lib-apt.outputs.cache-hit }}
1 change: 1 addition & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
with:
deploy-user: ${{ github.actor }}
deploy-token: ${{ secrets.GITHUB_TOKEN }}
cache-key: ${{ matrix.image-name }}
- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
if: ${{ env.PUSH_MASTER }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
with:
deploy-user: ${{ github.actor }}
deploy-token: ${{ secrets.GITHUB_TOKEN }}
cache-key: ${{ matrix.image-name }}

- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
with:
deploy-user: ${{ github.actor }}
deploy-token: ${{ secrets.GITHUB_TOKEN }}
cache-key: ${{ matrix.image-name }}
- name: Build ${{ matrix.image-name }} image
uses: docker/build-push-action@v5
with:
Expand Down

0 comments on commit 3cf1f29

Please sign in to comment.