forked from open-metadata/OpenMetadata
-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (130 loc) · 5.38 KB
/
Copy pathdocker-k8s-operator.yml
File metadata and controls
147 lines (130 loc) · 5.38 KB
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
142
143
144
145
146
147
# Copyright 2021 Collate
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: docker-k8s-operator release app
on:
workflow_dispatch:
inputs:
docker_release_tag:
description: "K8s Operator Docker Image Tag"
required: true
push_latest_tag_to_release:
description: "Do you want to update docker image latest tag as well ?"
type: boolean
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
maven-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
- name: Build K8s Operator Application
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -DskipTests clean package -pl openmetadata-k8s-operator -am
- name: Run K8s Operator Tests
run: |
mvn test -pl openmetadata-k8s-operator
- name: Upload K8s Operator JAR to Artifact
uses: actions/upload-artifact@v4
with:
name: k8s-operator-binary
path: openmetadata-k8s-operator/target/*.jar
release-project-event-workflow_dispatch:
if: github.event_name == 'workflow_dispatch'
name: Release k8s operator with workflow_dispatch event
runs-on: ubuntu-latest
needs: maven-build
steps:
- name: Fetch Release Data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: attach_release
run: |
echo "UPLOAD_URL=$(curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/open-metadata/OpenMetadata/releases/tags/${{ inputs.docker_release_tag }}-release | jq .upload_url | tr -d '"' )" >> $GITHUB_OUTPUT
- name: Download application from Artifact
uses: actions/download-artifact@v4
with:
name: k8s-operator-binary
- name: Upload k8s operator to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_path: ./openmetadata-k8s-operator-${{ inputs.docker_release_tag }}-boot.jar
upload_url: ${{ steps.attach_release.outputs.UPLOAD_URL }}
asset_name: openmetadata-k8s-operator-${{ inputs.docker_release_tag }}.jar
asset_content_type: application/java-archive
push_to_docker_hub:
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs: [ maven-build ]
steps:
- name: Wait for the labeler
uses: lewagon/wait-on-check-action@v1.7.0
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
check-name: Team Label
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 90
- name: Verify PR labels
uses: jesusvasquez333/verify-pr-label-action@v1.4.0
if: ${{ github.event_name == 'pull_request_target' }}
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
valid-labels: "safe to test"
pull-request-number: "${{ github.event.pull_request.number }}"
disable-reviews: true
- name: Check out the Repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Download application from Artifact
uses: actions/download-artifact@v4
with:
name: k8s-operator-binary
path: openmetadata-k8s-operator/target/
- name: Set build arguments
id: build-args
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Prepare for Docker Build&Push
id: prepare
uses: ./.github/actions/prepare-for-docker-build-and-push
with:
image: openmetadata/omjob-operator
tag: ${{ inputs.docker_release_tag || 'pr-test' }}
push_latest: ${{ inputs.push_latest_tag_to_release || false }}
dockerhub_username: ${{ secrets.DOCKERHUB_OPENMETADATA_USERNAME }}
dockerhub_token: ${{ secrets.DOCKERHUB_OPENMETADATA_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: ./openmetadata-k8s-operator
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'workflow_dispatch' }}
tags: ${{ steps.prepare.outputs.tags }}
file: ./openmetadata-k8s-operator/Dockerfile
build-args: |
BUILD_DATE=${{ steps.build-args.outputs.BUILD_DATE }}
COMMIT_ID=${{ github.sha }}