Skip to content

Commit bbf6b40

Browse files
feat: ✨ use cache between docker builds
1 parent 8413ce3 commit bbf6b40

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

.github/workflows/release.yml

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
env:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757

58-
docker_push:
59-
name: Docker Build & Push
58+
docker_build:
59+
name: Docker Build
6060
runs-on: ubuntu-latest
6161
needs: [test]
6262

@@ -71,15 +71,44 @@ jobs:
7171
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
7272
echo "NOW=$(date --utc +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
7373
74-
- name: Build & push Docker image to ghcr.io
75-
uses: mr-smithers-excellent/docker-build-push@v6
74+
- name: Cache Docker layers
75+
uses: actions/cache@v3
76+
with:
77+
path: /tmp/.buildx-cache
78+
key: ${{ runner.os }}-buildx-${{ github.sha }}
79+
restore-keys: |
80+
${{ runner.os }}-buildx-
81+
82+
- name: Set up QEMU
83+
uses: docker/setup-qemu-action@v3
84+
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v3
87+
88+
- name: Login to GitHub Container Registry
89+
uses: docker/login-action@v3
7690
with:
77-
image: git-sync
78-
tags: ${{ env.RELEASE_VERSION }},latest
7991
registry: ghcr.io
80-
multiPlatform: true
81-
platform: linux/amd64,linux/arm64,linux/arm/v7
8292
username: ${{ github.actor }}
8393
password: ${{ secrets.GITHUB_TOKEN }}
84-
buildArgs: 'VERSION=${{ env.RELEASE_VERSION }},BUILD=${{ env.NOW }}'
8594

95+
- name: Build & push Docker image to ghcr.io
96+
uses: docker/build-push-action@v4
97+
with:
98+
context: .
99+
push: true
100+
tags: |
101+
- ghcr.io/${{ github.repository }}:${{ env.RELEASE_VERSION }}
102+
- ghcr.io/${{ github.repository }}:latest
103+
platforms: |
104+
- linux/amd64
105+
- linux/arm64
106+
- linux/arm/v7
107+
build-args: |
108+
VERSION=${{ env.RELEASE_VERSION }}
109+
BUILD_DATE=${{ env.NOW }}
110+
cache-from: type=local,src=/tmp/.buildx-cache
111+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
112+
113+
- name: Move new cache to old cache
114+
run: mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 commit comments

Comments
 (0)