Skip to content

Commit acfb85c

Browse files
committed
feat(ci): add docker build dry run
1 parent d38b621 commit acfb85c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/build.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Docker dry run
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
schedule:
9+
- cron: '0 0 * * *' # every day at 00:00
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Prepare
18+
id: prep
19+
run: |
20+
TAG=$(echo $GITHUB_SHA | head -c7)
21+
IMAGE="klickhouse-example-img"
22+
echo "tagged_image=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT
23+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
24+
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: docker/setup-buildx-action@v3
28+
with:
29+
install: true
30+
31+
- name: Cache Docker layers
32+
uses: actions/cache@v4
33+
with:
34+
path: /tmp/.buildx-cache
35+
key: ${{ runner.os }}-buildx-${{ github.sha }}
36+
restore-keys: |
37+
${{ runner.os }}-buildx-
38+
39+
- name: Docker build
40+
uses: docker/build-push-action@v5
41+
with:
42+
builder: ${{ steps.buildx.outputs.name }}
43+
push: false
44+
context: .
45+
tags: ${{ steps.prep.outputs.tagged_image }}
46+
cache-from: type=local,src=/tmp/.buildx-cache
47+
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
48+
49+
- name: Move cache
50+
run: |
51+
rm -rf /tmp/.buildx-cache
52+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 commit comments

Comments
 (0)