@@ -2,63 +2,52 @@ name: Build Docker image
22
33on :
44 push :
5- tags : ['v*']
5+ branches :
6+ - develop
7+ - main
8+ tags :
9+ - v*
10+ workflow_dispatch :
611
712jobs :
8- build-amd :
13+ build :
914 runs-on : ubuntu-latest
15+ env :
16+ GIT_REF : ${{ github.head_ref || github.ref_name }} # ref_name to get tags/branches
17+ permissions :
18+ contents : read
19+ packages : write
1020 steps :
11- - name : Check out the repo
12- uses : actions/checkout@v3
21+ - name : Checkout
22+ uses : actions/checkout@v4
1323
14- - name : Extract existing image metadata
15- id : image-meta
16- uses : docker/metadata-action@v4
17- with :
18- images : atendai/evolution-api
24+ - name : Set up QEMU
25+ uses : docker/setup-qemu-action@v3
1926
2027 - name : Set up Docker Buildx
21- uses : docker/setup-buildx-action@v2
22-
23- - name : Log in to Docker Hub
24- uses : docker/login-action@v2
25- with :
26- username : ${{ secrets.DOCKER_USERNAME }}
27- password : ${{ secrets.DOCKER_PASSWORD }}
28+ uses : docker/setup-buildx-action@v3
2829
29- - name : Build and push AMD image
30- uses : docker/build-push-action@v4
31- with :
32- context : .
33- labels : ${{ steps.image-meta.outputs.labels }}
34- platforms : linux/amd64
35- push : true
30+ - name : set docker tag
31+ run : |
32+ echo "DOCKER_TAG=ghcr.io/atendai/evolution-api:$GIT_REF" >> $GITHUB_ENV
3633
37- build-arm :
38- runs-on : buildjet-4vcpu-ubuntu-2204-arm
39- steps :
40- - name : Check out the repo
41- uses : actions/checkout@v3
42-
43- - name : Extract existing image metadata
44- id : image-meta
45- uses : docker/metadata-action@v4
46- with :
47- images : atendai/evolution-api
48-
49- - name : Set up Docker Buildx
50- uses : docker/setup-buildx-action@v2
34+ - name : replace docker tag if main
35+ if : github.ref_name == 'main'
36+ run : |
37+ echo "DOCKER_TAG=ghcr.io/atendai/evolution-api:latest" >> $GITHUB_ENV
5138
52- - name : Log in to Docker Hub
53- uses : docker/login-action@v2
39+ - name : Login to GitHub Container Registry
40+ uses : docker/login-action@v3
5441 with :
55- username : ${{ secrets.DOCKER_USERNAME }}
56- password : ${{ secrets.DOCKER_PASSWORD }}
42+ registry : ghcr.io
43+ username : ${{ github.actor }}
44+ password : ${{ secrets.GITHUB_TOKEN }}
5745
58- - name : Build and push ARM image
59- uses : docker/build-push-action@v4
46+ - name : Build and push
47+ uses : docker/build-push-action@v2
6048 with :
6149 context : .
62- labels : ${{ steps.image-meta.outputs.labels }}
63- platforms : linux/arm64
50+ file : ./Dockerfile
51+ platforms : linux/amd64,linux/ arm64
6452 push : true
53+ tags : ${{ env.DOCKER_TAG }}
0 commit comments