Skip to content

Commit 28e1dce

Browse files
committed
feat(gh-action): fix docker implementation
1 parent b909457 commit 28e1dce

File tree

1 file changed

+30
-14
lines changed

1 file changed

+30
-14
lines changed

.github/workflows/build_and_push.yml

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,43 @@ jobs:
99
build:
1010
name: Build Docker Image
1111
runs-on: ubuntu-latest
12+
env:
13+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
14+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
1215

1316
steps:
1417
- name: Checkout repository
15-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1619

1720
- name: Set up Docker Buildx
18-
uses: docker/setup-buildx-action@v1
21+
uses: docker/setup-buildx-action@v3
1922

2023
- name: Log in to Docker Hub
21-
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
24+
uses: docker/login-action@v3
25+
with:
26+
username: ${{ secrets.DOCKER_USERNAME }}
27+
password: ${{ secrets.DOCKER_PASSWORD }}
28+
29+
- name: Cache Docker layers
30+
uses: actions/cache@v3
31+
with:
32+
path: /tmp/.buildx-cache
33+
key: ${{ runner.os }}-buildx-${{ github.sha }}
34+
restore-keys: |
35+
${{ runner.os }}-buildx-
2236
2337
- name: Build and push Docker image
24-
run: |
25-
docker buildx build \
26-
--file Dockerfile \
27-
--tag numberlyinfra/vault-injector:${{ github.ref_name }} \
28-
--cache-from type=local,src=$HOME/.docker/.cache \
29-
--cache-to type=local,dest=$HOME/.docker/.cache \
30-
--platform linux/amd64,linux/arm64 \
31-
--push .
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
file: Dockerfile
42+
platforms: linux/amd64,linux/arm64
43+
push: true
44+
tags: numberlyinfra/vault-injector:${{ github.ref_name }}
45+
cache-from: type=local,src=/tmp/.buildx-cache
46+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
3247

33-
env:
34-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
35-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
48+
- name: Move cache
49+
run: |
50+
rm -rf /tmp/.buildx-cache
51+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

0 commit comments

Comments
 (0)