9
9
build :
10
10
name : Build Docker Image
11
11
runs-on : ubuntu-latest
12
+ env :
13
+ DOCKER_USERNAME : ${{ secrets.DOCKER_USERNAME }}
14
+ DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
12
15
13
16
steps :
14
17
- name : Checkout repository
15
- uses : actions/checkout@v2
18
+ uses : actions/checkout@v4
16
19
17
20
- name : Set up Docker Buildx
18
- uses : docker/setup-buildx-action@v1
21
+ uses : docker/setup-buildx-action@v3
19
22
20
23
- 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-
22
36
23
37
- 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
32
47
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