-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (59 loc) · 1.84 KB
/
build-push-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
on:
push:
branches:
- main*
tags:
- 'v*'
name: Build and Publish Docker Image
jobs:
build-docker:
runs-on: ubuntu-latest
name: Build Docker Image
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: docker/setup-buildx-action@v2
- name: Define docker image meta data tags
id: meta
uses: docker/metadata-action@v4
with:
images: |
mayalabs/maya
ghcr.io/mayalabs/maya
tags: |
# Tag "git short sha" on all git events
type=sha,prefix=
# Tag "next" on git-push-to-main-branch events
type=raw,value=next,event=branch,enable={{is_default_branch}}
# Tag "latest" on git-tag events
type=raw,value=latest,event=tag
# Tag "$APP_VERSION" on git-push-to-branch events
type=raw,value=${{ env.APP_VERSION }},event=branch
# Tag "tag ref" on git-tag events
type=ref,event=tag
# - name: Login to Github container registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
GITHUB_SHA=${{ github.sha }}
GO_BUILD_FLAG=${{ env.GO_BUILD_FLAG }}
tags: ${{ steps.meta.outputs.tags }}
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short=7 ${{ github.sha }})
echo "::set-output name=short_sha::$calculatedSha"