-
Notifications
You must be signed in to change notification settings - Fork 273
172 lines (145 loc) · 5.89 KB
/
operator.yaml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Operator Test Workflow
on:
push:
branches:
- main
paths:
- operator/**
pull_request:
branches:
- main
paths:
- operator/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
operator-build-test:
name: Build and Test Operator
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio' && !contains(github.event.*.labels.*.name, 'DO NOT MERGE')
steps:
- name: Configure env. variables 1
run: |
echo "UUID=$(uuidgen)" >> $GITHUB_ENV
# We need tho push the bundle image because opm always pulls; the catalog image because OLM
# deploys it with `imagePullPolicy: Always`; and also the operator image itself for the same reason.
- name: Configure env. variables 2
run: |
echo "IMAGE=ttl.sh/apicurio-registry-3-operator-$UUID:8h" >> $GITHUB_ENV
echo "BUNDLE_IMAGE=ttl.sh/apicurio-registry-3-operator-bundle-$UUID:8h" >> $GITHUB_ENV
echo "CATALOG_IMAGE=ttl.sh/apicurio-registry-3-operator-catalog-$UUID:8h" >> $GITHUB_ENV
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
cache: maven
- uses: ./.github/workflows/composite/setup-minikube
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Build only
if: github.event_name != 'push'
working-directory: operator
run: |
make BUILD_OPTS=--no-transfer-progress SKIP_TESTS=true build
- name: Build and run local tests on Minikube
# Speed up the PR check by running both local and remote tests on push to main,
# and only run remote tests against a PR.
# TODO: Is this ok?
if: github.event_name == 'push'
working-directory: operator
run: |
make BUILD_OPTS=--no-transfer-progress build
- name: Build temporary operator image
working-directory: operator
run: |
make image-build image-push
- name: Build temporary operator bundle
working-directory: operator
run: |
make bundle
- name: Build temporary operator catalog
working-directory: operator
run: |
make catalog
- name: Run remote and OLM tests on Minikube
working-directory: operator
run: |
make BUILD_OPTS=--no-transfer-progress remote-tests-all
- name: Update install file
working-directory: operator
run: |
# We need to remove unset the variables to generate a clean install file.
# See https://github.com/actions/runner/issues/1126
unset IMAGE
unset BUNDLE_IMAGE
unset CATALOG_IMAGE
make IMAGE_TAG=latest-snapshot INSTALL_FILE=install/install.yaml dist-install-file
- name: Check install file
run: |
git add operator/install/install.yaml || true
if ! git diff --staged --exit-code; then
echo 'Install file needs to be updated. Please run "cd operator; make SKIP_TESTS=true build IMAGE_TAG=latest-snapshot INSTALL_FILE=install/install.yaml dist-install-file" and commit the result.';
exit 1;
else
echo "No changes to the install file.";
fi
operator-publish:
name: Publish Operator
runs-on: ubuntu-latest
needs: operator-build-test
if: github.event_name == 'push'
steps:
- name: Configure env. variables
run: |
# We want to use latest-snapshot instead of x.y.z-snapshot
echo "IMAGE_TAG=latest-snapshot" >> $GITHUB_ENV
echo "BUNDLE_IMAGE_TAG=latest-snapshot" >> $GITHUB_ENV
echo "CATALOG_IMAGE_TAG=latest-snapshot" >> $GITHUB_ENV
- name: Checkout ${{ github.ref }}
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
cache: maven
- name: Build
working-directory: operator
run: |
make BUILD_OPTS=--no-transfer-progress SKIP_TESTS=true build
- name: Login to quay.io registry
run: |
docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" quay.io
# TODO: Also push to DockerHub Registry
- name: Build and publish operator image
working-directory: operator
run: |
make image-build image-push
- name: Build and publish operator bundle
working-directory: operator
run: |
make bundle
- name: Build and publish operator catalog
working-directory: operator
run: |
make catalog
- name: Slack Notification (Always)
if: always()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job completed with status: ${{ job.status }}"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "${{ secrets.SLACK_NOTIFICATION_WEBHOOK }}"
- name: Slack Notification (Error)
if: failure()
run: |
MESSAGE="'${{ github.workflow }}/${{ github.job }}' job FAILED!"
REPO="${{ github.repository }}"
LINK="https://github.com/$REPO/actions/runs/${{ github.run_id }}"
PAYLOAD="{\"workflow\": \"${{ github.workflow }}\", \"status\": \"${{ job.status }}\", \"message\": \"$MESSAGE\", \"link\": \"$LINK\", \"repository\": \"$REPO\"}"
curl -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "${{ secrets.SLACK_ERROR_WEBHOOK }}"