-
Notifications
You must be signed in to change notification settings - Fork 392
141 lines (128 loc) · 5.69 KB
/
docker-image.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Publish Docker Image
on:
workflow_dispatch:
inputs:
image:
type: choice
description: 'Choose the image to build'
required: true
default: 'gravitino'
options:
- 'gravitino'
- 'gravitino-ci:hive'
- 'gravitino-ci:kerberos-hive'
- 'gravitino-ci:trino'
- 'gravitino-ci:doris'
- 'gravitino-ci:ranger'
- 'gravitino-playground:trino'
- 'gravitino-playground:hive'
- 'gravitino-playground:ranger'
- 'gravitino-iceberg-rest-server'
version:
description: 'Docker version to apply to this image'
required: true
type: string
username:
description: 'Docker username'
required: true
type: string
token:
description: 'Publish Docker token'
required: true
type: string
publish-latest-tag:
description: 'Whether to update the latest tag. This operation is only applicable to official releases and should not be used for Release Candidate (RC).'
required: false
type: boolean
default: false
jobs:
publish-docker-image:
runs-on: ubuntu-latest
timeout-minutes: 120
env:
input_token: ${{ github.event.inputs.token }}
secrets_token: ${{ secrets.PUBLISH_DOCKER_TOKEN }}
steps:
- name: Set environment variables
run: |
if [ "${{ github.event.inputs.image }}" == "gravitino-ci:hive" ]; then
echo "image_type=hive" >> $GITHUB_ENV
echo "image_name=apache/gravitino-ci" >> $GITHUB_ENV
echo "tag_name=hive" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-ci:kerberos-hive" ]; then
echo "image_type=kerberos-hive" >> $GITHUB_ENV
echo "image_name=apache/gravitino-ci" >> $GITHUB_ENV
echo "tag_name=kerberos-hive" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-ci:trino" ]; then
echo "image_type=trino" >> $GITHUB_ENV
echo "image_name=apache/gravitino-ci" >> $GITHUB_ENV
echo "tag_name=trino" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-ci:doris" ]; then
echo "image_type=doris" >> $GITHUB_ENV
echo "image_name=apache/gravitino-ci" >> $GITHUB_ENV
echo "tag_name=doris" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-ci:ranger" ]; then
echo "image_type=ranger" >> $GITHUB_ENV
echo "image_name=apache/gravitino-ci" >> $GITHUB_ENV
echo "tag_name=ranger" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino" ]; then
echo "image_type=gravitino" >> $GITHUB_ENV
echo "image_name=apache/gravitino" >> $GITHUB_ENV
# `apache/gravitino` is the default image name, didn't need to tag alias name
elif [ "${{ github.event.inputs.image }}" == "gravitino-playground:trino" ]; then
echo "image_type=trino" >> $GITHUB_ENV
echo "image_name=apache/gravitino-playground" >> $GITHUB_ENV
echo "tag_name=trino" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-playground:hive" ]; then
echo "image_type=hive" >> $GITHUB_ENV
echo "image_name=apache/gravitino-playground" >> $GITHUB_ENV
echo "tag_name=hive" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-playground:ranger" ]; then
echo "image_type=ranger" >> $GITHUB_ENV
echo "image_name=apache/gravitino-playground" >> $GITHUB_ENV
echo "tag_name=ranger" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.image }}" == "gravitino-iceberg-rest-server" ]; then
echo "image_type=iceberg-rest-server" >> $GITHUB_ENV
echo "image_name=apache/gravitino-iceberg-rest" >> $GITHUB_ENV
fi
if [ "${{ github.event.inputs.publish-latest-tag }}" == "true" ]; then
echo "publish_latest=true" >> $GITHUB_ENV
else
echo "publish_latest=false" >> $GITHUB_ENV
fi
- name: Check publish Docker token
run: |
if [[ "${secrets_token}" != "${input_token}" ]]; then
echo "You have entered an incorrect token. Please re-enter it."
exit 1
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ github.event.inputs.username }}
password: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build and Push the Docker image
run: |
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/hostedtoolcache/CodeQL
if [[ -n "${tag_name}" ]]; then
full_tag_name="${tag_name}-${{ github.event.inputs.version }}"
else
full_tag_name="${{ github.event.inputs.version }}"
fi
if [[ "${publish_latest}" == "true" ]]; then
echo "Publish tag ${full_tag_name}, and update latest too."
./dev/docker/build-docker.sh --platform all --type ${image_type} --image ${image_name} --tag ${full_tag_name} --latest
else
echo "Publish tag ${full_tag_name}."
./dev/docker/build-docker.sh --platform all --type ${image_type} --image ${image_name} --tag ${full_tag_name}
fi