Repository navigation
126 lines (111 loc) · 4.34 KB
/
Copy pathdocker-k8s-operator.yml
File metadata and controls
126 lines (111 loc) · 4.34 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
# 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
permissions:
contents: read
jobs:
maven-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Set up JDK 21
uses: actions/setup-java@v6
with:
java-version: 21
distribution: 'temurin'
- name: Build K8s Operator Application
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mvn -DskipTests clean install -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@v7
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
# `gh release upload` needs write, overriding the workflow-level read.
permissions:
contents: write
needs: maven-build
steps:
- name: Download application from Artifact
uses: actions/download-artifact@v8
with:
name: k8s-operator-binary
- name: Upload k8s operator to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ inputs.docker_release_tag }}
run: |
cp "openmetadata-k8s-operator-${RELEASE_TAG}-boot.jar" "openmetadata-k8s-operator-${RELEASE_TAG}.jar"
gh release upload "${RELEASE_TAG}-release" "openmetadata-k8s-operator-${RELEASE_TAG}.jar" --repo "${GITHUB_REPOSITORY}"
push_to_docker_hub:
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs: [ maven-build ]
steps:
- name: Check out the Repo
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
- name: Download application from Artifact
uses: actions/download-artifact@v8
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@v7
env:
DOCKER_BUILD_SUMMARY: false
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 }}