Skip to content

Commit b40e4e7

Browse files
authored
Merge pull request #21801 from dvdksn/gha-runner-tmp-dir
build: replace absolute /tmp with runner context temp dir
2 parents ff148d0 + 7bd2b73 commit b40e4e7

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

content/manuals/build/ci/github-actions/cache.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ jobs:
248248
- name: Cache Docker layers
249249
uses: actions/cache@v4
250250
with:
251-
path: /tmp/.buildx-cache
251+
path: ${{ runner.temp }}/.buildx-cache
252252
key: ${{ runner.os }}-buildx-${{ github.sha }}
253253
restore-keys: |
254254
${{ runner.os }}-buildx-
@@ -258,14 +258,14 @@ jobs:
258258
with:
259259
push: true
260260
tags: user/app:latest
261-
cache-from: type=local,src=/tmp/.buildx-cache
262-
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
261+
cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
262+
cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max
263263
264264
- # Temp fix
265265
# https://github.com/docker/build-push-action/issues/252
266266
# https://github.com/moby/buildkit/issues/1896
267267
name: Move cache
268268
run: |
269-
rm -rf /tmp/.buildx-cache
270-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
269+
rm -rf ${{ runner.temp }}/.buildx-cache
270+
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
271271
```

content/manuals/build/ci/github-actions/multi-platform.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,15 @@ jobs:
179179
180180
- name: Export digest
181181
run: |
182-
mkdir -p /tmp/digests
182+
mkdir -p ${{ runner.temp }}/digests
183183
digest="${{ steps.build.outputs.digest }}"
184-
touch "/tmp/digests/${digest#sha256:}"
184+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
185185
186186
- name: Upload digest
187187
uses: actions/upload-artifact@v4
188188
with:
189189
name: digests-${{ env.PLATFORM_PAIR }}
190-
path: /tmp/digests/*
190+
path: ${{ runner.temp }}/digests/*
191191
if-no-files-found: error
192192
retention-days: 1
193193
@@ -199,7 +199,7 @@ jobs:
199199
- name: Download digests
200200
uses: actions/download-artifact@v4
201201
with:
202-
path: /tmp/digests
202+
path: ${{ runner.temp }}/digests
203203
pattern: digests-*
204204
merge-multiple: true
205205
@@ -233,7 +233,7 @@ jobs:
233233
type=semver,pattern={{major}}.{{minor}}
234234
235235
- name: Create manifest list and push
236-
working-directory: /tmp/digests
236+
working-directory: ${{ runner.temp }}/digests
237237
run: |
238238
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
239239
$(printf '${{ env.DOCKERHUB_REPO }}@sha256:%s ' *)
@@ -326,13 +326,13 @@ jobs:
326326
327327
- name: Rename meta bake definition file
328328
run: |
329-
mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json"
329+
mv "${{ steps.meta.outputs.bake-file }}" "${{ runner.temp }}/bake-meta.json"
330330
331331
- name: Upload meta bake definition
332332
uses: actions/upload-artifact@v4
333333
with:
334334
name: bake-meta
335-
path: /tmp/bake-meta.json
335+
path: ${{ runner.temp }}/bake-meta.json
336336
if-no-files-found: error
337337
retention-days: 1
338338
@@ -354,7 +354,7 @@ jobs:
354354
uses: actions/download-artifact@v4
355355
with:
356356
name: bake-meta
357-
path: /tmp
357+
path: ${{ runner.temp }}
358358
359359
- name: Login to Docker Hub
360360
uses: docker/login-action@v3
@@ -374,7 +374,7 @@ jobs:
374374
with:
375375
files: |
376376
./docker-bake.hcl
377-
cwd:///tmp/bake-meta.json
377+
cwd://${{ runner.temp }}/bake-meta.json
378378
targets: image
379379
set: |
380380
*.tags=
@@ -383,15 +383,15 @@ jobs:
383383
384384
- name: Export digest
385385
run: |
386-
mkdir -p /tmp/digests
386+
mkdir -p ${{ runner.temp }}/digests
387387
digest="${{ fromJSON(steps.bake.outputs.metadata).image['containerimage.digest'] }}"
388-
touch "/tmp/digests/${digest#sha256:}"
388+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
389389
390390
- name: Upload digest
391391
uses: actions/upload-artifact@v4
392392
with:
393393
name: digests-${{ env.PLATFORM_PAIR }}
394-
path: /tmp/digests/*
394+
path: ${{ runner.temp }}/digests/*
395395
if-no-files-found: error
396396
retention-days: 1
397397
@@ -404,12 +404,12 @@ jobs:
404404
uses: actions/download-artifact@v4
405405
with:
406406
name: bake-meta
407-
path: /tmp
407+
path: ${{ runner.temp }}
408408
409409
- name: Download digests
410410
uses: actions/download-artifact@v4
411411
with:
412-
path: /tmp/digests
412+
path: ${{ runner.temp }}/digests
413413
pattern: digests-*
414414
merge-multiple: true
415415
@@ -423,12 +423,12 @@ jobs:
423423
uses: docker/setup-buildx-action@v3
424424
425425
- name: Create manifest list and push
426-
working-directory: /tmp/digests
426+
working-directory: ${{ runner.temp }}/digests
427427
run: |
428-
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' /tmp/bake-meta.json) \
428+
docker buildx imagetools create $(jq -cr '.target."docker-metadata-action".tags | map(select(startswith("${{ env.REGISTRY_IMAGE }}")) | "-t " + .) | join(" ")' ${{ runner.temp }}/bake-meta.json) \
429429
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
430430
431431
- name: Inspect image
432432
run: |
433-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' /tmp/bake-meta.json)
433+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(jq -r '.target."docker-metadata-action".args.DOCKER_META_VERSION' ${{ runner.temp }}/bake-meta.json)
434434
```

content/manuals/build/ci/github-actions/share-image-jobs.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
uses: docker/build-push-action@v6
3030
with:
3131
tags: myimage:latest
32-
outputs: type=docker,dest=/tmp/myimage.tar
32+
outputs: type=docker,dest=${{ runner.temp }}/myimage.tar
3333

3434
- name: Upload artifact
3535
uses: actions/upload-artifact@v4
3636
with:
3737
name: myimage
38-
path: /tmp/myimage.tar
38+
path: ${{ runner.temp }}/myimage.tar
3939

4040
use:
4141
runs-on: ubuntu-latest
@@ -45,10 +45,10 @@ jobs:
4545
uses: actions/download-artifact@v4
4646
with:
4747
name: myimage
48-
path: /tmp
48+
path: ${{ runner.temp }}
4949

5050
- name: Load image
5151
run: |
52-
docker load --input /tmp/myimage.tar
52+
docker load --input ${{ runner.temp }}/myimage.tar
5353
docker image ls -a
5454
```

0 commit comments

Comments
 (0)