@@ -22,12 +22,6 @@ inputs:
2222 description : User name to use when pushing images to Docker Hub
2323 dockerhub_token :
2424 description : Docker Hub token to use
25- cache_mounts :
26- description : Load cache mounts cache
27- default : |
28- cargo_registry_index
29- cargo_registry_cache
30- cargo_git
3125 cargo_profile :
3226 description : Cargo build profile, i.e release or dev
3327 default : dev
@@ -43,6 +37,9 @@ inputs:
4337 aws_secret_access_key :
4438 description : AWS secret access key
4539 required : true
40+ cache_to_name :
41+ description : ' Save cache to name manifest (should be used only on default branch)'
42+ default : ' false'
4643outputs :
4744 digest :
4845 value : ${{ steps.docker_build.outputs.digest }}
@@ -65,17 +62,10 @@ runs:
6562 install : true
6663 driver-opts : env.BUILDKIT_STEP_LOG_MAX_SIZE=10485760
6764 cleanup : false
68- config-inline : |
65+ buildkitd- config-inline : |
6966 [worker.oci]
7067 gc = false
7168
72- - name : Load Docker mount cache
73- uses : dcginfra/buildkit-cache-dance/inject@s5cmd
74- if : ${{ inputs.cache_mounts != '' }}
75- with :
76- bucket : ${{ inputs.bucket }}
77- mounts : ${{ inputs.cache_mounts }}
78-
7969 - name : Set Docker tags and labels from image tag
8070 id : docker_meta
8171 uses : docker/metadata-action@v5
@@ -90,16 +80,83 @@ runs:
9080 id : layer_cache_settings
9181 with :
9282 name : ${{ inputs.image_name }}
83+ region : ${{ inputs.region }}
9384 bucket : ${{ inputs.bucket }}
85+ cache_to_name : ${{ inputs.cache_to_name }}
86+
87+ - name : Set HOME variable to github context
88+ shell : bash
89+ run : echo "HOME=$HOME" >> $GITHUB_ENV
90+
91+ - name : Cargo cache for Docker
92+ uses : actions/cache@v4
93+ id : cargo-cache
94+ with :
95+ path : |
96+ ${{ env.HOME }}/cargo-cache-registry-index
97+ ${{ env.HOME }}/cargo-cache-registry-cache
98+ ${{ env.HOME }}/cargo-cache-git-db
99+ key : ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
100+ restore-keys : |
101+ ${{ runner.os }}-cargo-
102+
103+ - name : Inject cargo cache into docker
104+ uses :
reproducible-containers/[email protected] 105+ with :
106+ cache-map : |
107+ {
108+ "${{ env.HOME }}/cargo-cache-registry-index": {
109+ "target": "/root/.cargo/registry/index",
110+ "id": "cargo_registry_index"
111+ },
112+ "${{ env.HOME }}/cargo-cache-registry-cache": {
113+ "target": "/root/.cargo/registry/cache",
114+ "id": "cargo_registry_cache"
115+ },
116+ "${{ env.HOME }}/cargo-cache-git-db": {
117+ "target": "/root/.cargo/git/db",
118+ "id": "cargo_git"
119+ }
120+ }
121+ skip-extraction : ${{ steps.cargo-cache.outputs.cache-hit }}
122+
123+ - name : Yarn unplugged cache for Docker
124+ uses : actions/cache@v4
125+ id : yarn-cache
126+ with :
127+ path : ${{ env.HOME }}/yarn-unplugged-cache
128+ key : ${{ inputs.platform }}-yarn-unplugged-${{ hashFiles('yarn.lock') }}
129+ restore-keys : |
130+ ${{ inputs.platform }}-yarn-unplugged-
131+
132+ - name : Set arch
133+ id : arch
134+ uses : actions/github-script@v6
135+ with :
136+ result-encoding : ' string'
137+ script : return '${{ inputs.platform }}'.replace('linux/', '');
138+
139+ - name : Inject cargo cache into docker
140+ uses :
reproducible-containers/[email protected] 141+ with :
142+ cache-map : |
143+ {
144+ "${{ env.HOME }}/yarn-unplugged-cache": {
145+ "target": "/tmp/unplugged",
146+ "id": "unplugged_${{ steps.arch.outputs.result }}"
147+ }
148+ }
149+ skip-extraction : ${{ steps.yarn-cache.outputs.cache-hit }}
94150
95151 - name : Build and push Docker image ${{ inputs.image }}
96152 id : docker_build
97- uses : docker/build-push-action@v5
153+ uses : docker/build-push-action@v6
98154 with :
99155 context : .
100156 builder : ${{ steps.buildx.outputs.name }}
101157 target : ${{ inputs.target }}
102158 labels : ${{ steps.docker_meta.outputs.labels }}
159+ push : ${{ inputs.push_tags }}
103160 tags : ${{ inputs.push_tags == 'true' && steps.docker_meta.outputs.tags || '' }}
104161 platforms : ${{ inputs.platform }}
105162 build-args : |
@@ -113,10 +170,3 @@ runs:
113170 cache-from : ${{ steps.layer_cache_settings.outputs.cache_from }}
114171 cache-to : ${{ steps.layer_cache_settings.outputs.cache_to }}
115172 outputs : type=image,name=${{ inputs.image_org }}/${{ inputs.image_name }},push-by-digest=${{ inputs.push_tags != 'true' }},name-canonical=true,push=true
116-
117- - name : Save Docker mount cache
118- uses : dcginfra/buildkit-cache-dance/extract@s5cmd
119- if : ${{ inputs.cache_mounts != '' }}
120- with :
121- bucket : ${{ inputs.bucket }}
122- mounts : ${{ inputs.cache_mounts }}
0 commit comments