forked from 4paradigm/OpenMLDB
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (84 loc) · 3.05 KB
/
hybridsql-docker.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# This workflow make compile docker image for OpenMLDB
name: HybridSQL Docker
on:
push:
branches:
- main
paths:
- .github/workflows/hybridsql-docker.yml
- docker/Dockerfile
- docker/**/*.sh
tags:
- 'v*.*.*'
# Run tests for any PRs.
pull_request:
paths:
- .github/workflows/hybridsql-docker.yml
- docker/Dockerfile
- docker/**/*.sh
workflow_dispatch:
env:
DOCKERHUB_REPO: 4pdosc
IMAGE_NAME: hybridsql
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
${{ env.DOCKERHUB_REPO }}/${{ env.IMAGE_NAME }}
flavor:
# turn latest=false to avoid generate latest tag for any 'docker-*' tag push event
# refer https://github.com/docker/metadata-action#latest-tag
latest=false
# expected tag results by trigger event
# 1. tag v0.4.1 -> [0.4, 0.4.1]
# 2. push to main -> latest
# 3. pull request -> pull request name (won't publish)
# 4. workflow_dispatch -> workflow_dispatch (won't publish)
tags: |
# tagging rules, means in order(event -> result tag):
# 1. push tag v0.4.1 -> 0.4.1
# 2. push tag v0.4.1 -> 0.4
# 3. pull request -> pull request name
# 4. push to main -> latest
# 5. workflow_dispatch -> workflow_dispatch
type=ref,event=pr
type=match,pattern=v(.*),group=1
type=match,pattern=v(\d.\d),group=1
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=workflow_dispatch,enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build And Push
id: docker_build
uses: docker/build-push-action@v3
with:
context: docker
push: ${{ github.event_name == 'push' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}