Skip to content

Commit 3ce0508

Browse files
authored
Merge pull request #20 from abkfenris/dependabot
Use Buildx in Github Actions
2 parents 24d4d08 + e3d512d commit 3ce0508

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

.github/workflows/push.yml

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Push
22

3-
on: [push, workflow_dispatch]
3+
on: [push, workflow_dispatch, pull_request]
4+
env:
5+
BUILDX_CACHE: /tmp/.buildx-cache
6+
CACHE_KEY: docker-erddap-buildx-
47

58
jobs:
69
build:
@@ -12,19 +15,32 @@ jobs:
1215
- name: Checkout
1316
uses: actions/checkout@v1
1417

15-
- name: Cache Docker Layers
16-
uses: satackey/action-docker-layer-caching@v0.0.11
17-
continue-on-error: true
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v1
20+
21+
- name: Cache Docker layers
22+
uses: actions/cache@v2
23+
with:
24+
path: ${ BUILDX_CACHE }
25+
key: ${ CACHE_KEY }${{ github.sha }}
26+
restore-keys: |
27+
${ CACHE_KEY }
1828
1929
- name: Login to Docker Hub
20-
uses: azure/docker-login@v1
30+
uses: docker/login-action@v1
2131
continue-on-error: true
2232
with:
2333
username: ${{ secrets.DOCKER_USERNAME }}
2434
password: ${{ secrets.DOCKER_PASSWORD }}
25-
26-
- name: Build Docker Image
27-
run: docker build --tag axiom/docker-erddap:latest .
35+
36+
- name: Build and push
37+
uses: docker/build-push-action@v2
38+
with:
39+
push: false
40+
tags: axiom/docker-erddap:latest
41+
cache-from: type=local,src=${ BUILDX_CACHE }
42+
cache-to: type=local,dest=${ BUILDX_CACHE }
43+
outputs: type=docker
2844

2945
- name: Run Docker Image in Background
3046
run: docker run -d -p 8080:8080 axiom/docker-erddap:latest
@@ -46,14 +62,27 @@ jobs:
4662
- name: Checkout
4763
uses: actions/checkout@v1
4864

49-
- name: Cache Docker Layers
50-
uses: satackey/action-docker-layer-caching@v0.0.11
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v1
67+
68+
- name: Cache Docker layers
69+
uses: actions/cache@v2
70+
with:
71+
path: ${ BUILDX_CACHE }
72+
key: ${ CACHE_KEY }${{ github.sha }}
73+
restore-keys: |
74+
${ CACHE_KEY }
5175
5276
- name: Login to Docker Hub
53-
uses: azure/docker-login@v1
77+
uses: docker/login-action@v1
5478
with:
5579
username: ${{ secrets.DOCKER_USERNAME }}
5680
password: ${{ secrets.DOCKER_PASSWORD }}
5781

5882
- name: Push latest image to Docker Hub if on master or main branch of Axiom's repo
59-
run: docker push axiom/docker-erddap:latest
83+
uses: docker/build-push-action@v2
84+
with:
85+
push: true
86+
tags: axiom/docker-erddap:latest
87+
cache-from: type=local,src=${ BUILDX_CACHE }
88+
cache-to: type=local,dest=${ BUILDX_CACHE }

0 commit comments

Comments
 (0)