Skip to content

Commit e22e7c6

Browse files
committed
better cache
1 parent 0a24c27 commit e22e7c6

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

.github/actions/container/ci/action.yaml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,28 @@ runs:
2525
driver-opts: network=host
2626

2727
- name: Cache Docker Buildx Layers
28+
id: cache
2829
uses: actions/cache@v4
2930
with:
30-
path: /tmp/.buildx-cache
31-
key: buildx-${{ inputs.git_ref }}
32-
restore-keys: |
33-
buildx-${{ inputs.git_ref }}
34-
buildx-edge
31+
path: |
32+
node
33+
python
34+
key: cache-${{ inputs.git_ref }}
35+
restore-keys: buildx-edge
3536

37+
- name: inject cache into docker
38+
uses: reproducible-containers/[email protected]
39+
with:
40+
cache-map: |
41+
{
42+
"node": "/root/.cache/yarn",
43+
"python": "/root/.cache/pip"
44+
}
45+
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
46+
47+
# Checkout already happened so that we may use this action.
48+
# Make sure we're on the right ref In case it was a tag.
49+
# So that we are using the Dockerfile on that inputs.git_ref
3650
- name: 'Fix actions/checkout odd handling of tags'
3751
if: startsWith(inputs.git_ref, 'refs/tags')
3852
shell: bash
@@ -50,10 +64,6 @@ runs:
5064
target: ci
5165
push: true
5266
tags: ghcr.io/opentrons/opentrons-ci:${{ inputs.git_ref }}
53-
cache-from: |
54-
type=local,src=/tmp/.buildx-cache
55-
type=registry,ref=ghcr.io/opentrons/opentrons-ci:cache
56-
cache-to: |
57-
type=local,dest=/tmp/.buildx-cache,mode=max
58-
type=registry,ref=ghcr.io/opentrons/opentrons-ci:cache,mode=max
67+
cache-from: type=gha
68+
cache-to: type=gha,mode=max
5969
secrets: GIT_AUTH_TOKEN=${{ inputs.token }}

ci-docker/Dockerfile

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,10 @@ ENV GIT_REF=${GIT_REF}
115115

116116
WORKDIR /opentrons
117117

118-
# Use a BuildKit cache mount. If `/tmp/git-repo` already exists, fetch & checkout.
119-
RUN --mount=type=cache,id=opentrons-git-cache,target=/tmp/git-repo \
120-
set -eux; \
121-
if [ -d /tmp/git-repo/.git ]; then \
122-
echo "Using cached Opentrons/opentrons repo in /tmp/git-repo"; \
123-
else \
124-
git clone https://github.com/Opentrons/opentrons.git /tmp/git-repo; \
125-
fi && \
126-
cd /tmp/git-repo; \
127-
git fetch --all; \
128-
git fetch --tags --force; \
129-
git fetch origin "${GIT_REF}"; \
130-
git checkout "${GIT_REF}"; \
131-
cp -r /tmp/git-repo/. /opentrons
118+
RUN git clone https://github.com/Opentrons/opentrons.git . \
119+
&& git fetch --tags --force \
120+
&& git fetch origin "${GIT_REF}" \
121+
&& git checkout "${GIT_REF}"
132122

133123
RUN --mount=type=cache,target=/root/.cache/yarn \
134124
bash -c "\

0 commit comments

Comments
 (0)