@@ -11,65 +11,43 @@ jobs:
11
11
env :
12
12
DOCKER_USER : ${{ secrets.CONTAINER_USERNAME }}
13
13
steps :
14
- - name : Compile tag list
15
- id : tags
16
- run : |
17
- TAG=${GITHUB_REF/refs\/tags\//}
18
- PREFIX=ghcr.io/laminas/laminas-continuous-integration
19
- MAJOR="${PREFIX}:$(echo ${TAG} | cut -d. -f1)"
20
- MINOR="${MAJOR}.$(echo ${TAG} | cut -d. -f2)"
21
- PATCH="${PREFIX}:${TAG}"
22
- echo "::set-output name=tags::[\"${MAJOR}\",\"${MINOR}\",\"${PATCH}\"]"
23
-
24
14
- name : Checkout
25
15
uses : actions/checkout@v2
26
16
27
- - name : Setup QEMU
28
- uses : docker/setup-qemu-action@v1
29
-
30
17
- name : Setup Docker Buildx
31
18
uses : docker/setup-buildx-action@v1
19
+ with :
20
+ install : true
32
21
33
22
- name : Login to GitHub Container Registry
34
- if : ${{ env.DOCKER_USER }}
23
+ if : ${{ github.event_name == 'release' }}
35
24
uses : docker/login-action@v1
36
25
with :
37
26
registry : ghcr.io
38
- username : ${{ env.DOCKER_USER }}
39
- password : ${{ secrets.CONTAINER_PAT }}
40
-
41
- - name : Build and push for release
42
- if : ${{ github.event_name == 'release' }}
43
- uses : docker/build-push-action@v2
44
- with :
45
- context : .
46
- file : ./Dockerfile
47
- platforms : linux/amd64
48
- pull : true
49
- push : true
50
- tags : ${{ join(fromJSON(steps.tags.outputs.tags), ',') }}
51
- cache-from : type=registry,ref=ghcr.io/laminas/laminas-continuous-integration-action:build-cache
52
- cache-to : type=registry,ref=ghcr.io/laminas/laminas-continuous-integration-action:build-cache,mode=max
27
+ username : ${{ github.repository_owner }}
28
+ password : ${{ secrets.GITHUB_TOKEN }}
53
29
54
- - name : Build for local pull request
55
- if : ${{ github.event_name == 'pull_request' && env.DOCKER_USER }}
56
- uses : docker/build-push- action@v2
30
+ - name : Docker meta
31
+ id : docker_meta
32
+ uses : docker/metadata- action@v3
57
33
with :
58
- context : .
59
- file : ./Dockerfile
60
- platforms : linux/amd64
61
- pull : true
62
- push : false
63
- cache-from : type=registry,ref=ghcr.io/laminas/laminas-continuous-integration-action:build-cache
64
- cache-to : type=registry,ref=ghcr.io/laminas/laminas-continuous-integration-action:build-cache,mode=max
65
-
66
- - name : Build for fork pull request
67
- if : ${{ github.event_name == 'pull_request' && ! env.DOCKER_USER }}
34
+ images : ghcr.io/laminas/laminas-continuous-integration
35
+ tags : |
36
+ type=semver,pattern={{version}}
37
+ type=ref,event=branch
38
+ type=ref,event=pr
39
+ flavor : |
40
+ latest=false
41
+
42
+ - name : Build image. Push for release
68
43
uses : docker/build-push-action@v2
69
44
with :
70
45
context : .
71
46
file : ./Dockerfile
72
- platforms : linux/amd64
73
47
pull : true
74
- push : false
75
- cache-from : type=registry,ref=ghcr.io/laminas/laminas-continuous-integration-action:build-cache
48
+ push : ${{ github.event_name == 'release' }}
49
+ tags : |
50
+ ${{ steps.docker_meta.outputs.tags }}
51
+ labels : ${{ steps.docker_meta.outputs.labels }}
52
+ cache-from : type=gha
53
+ cache-to : type=gha,mode=max
0 commit comments