forked from kroxylicious/kroxylicious
-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (95 loc) · 4.68 KB
/
docker.yaml
File metadata and controls
107 lines (95 loc) · 4.68 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
# docker.yaml - builds and pushes a kroxylicious container image.
#
# Requires repository variables:
# - REGISTRY_SERVER - the server of the container registry service e.g. `quay.io` or `docker.io`
# - REGISTRY_USERNAME - your username on the service (or username of your robot account)
# - REGISTRY_DESTINATION - the push destination (without tag portion) e.g. `quay.io/<my org>/kroxylicious`
# and a repository secret
# - REGISTRY_TOKEN - the access token that corresponds to `REGISTRY_USERNAME`
#
# If the required repository variables aren't set the workflow will be skipped. This means the workflow won't fail
# on the forks of developers who haven't configured the variables/secrets.
name: Docker Build
on:
workflow_dispatch:
push:
branches:
- 'main'
- 'release/**'
tags:
- 'v*.*.*'
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Test for Slack secret'
env:
KROXYLICIOUS_SLACK_WEBHOOK: ${{ secrets.KROXYLICIOUS_SLACK_WEBHOOK }}
run: |
echo "SLACK_WEBHOOK_SET=$(test ${KROXYLICIOUS_SLACK_WEBHOOK} && echo true)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
- name: Setup Java
uses: ./.github/actions/common/setup-java
- name: Determine Build Configuration
id: build_configuration
run: |
RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" == "pull_request" || "${{ vars.REGISTRY_SERVER }}" == "" ]]; then
echo "proxy_tags=kroxylicious-proxy:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "operator_tags=kroxylicious-operator:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "push_images=false" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
else
PROXY_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.PROXY_IMAGE_NAME }}"
OPERATOR_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.OPERATOR_IMAGE_NAME }}"
echo "proxy_tags=${PROXY_IMAGE}:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
echo "operator_tags=${OPERATOR_IMAGE}:${RELEASE_VERSION},${OPERATOR_IMAGE}:latest" >> $GITHUB_OUTPUT
echo "push_images=true" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
fi
- name: Login to container registry
if: steps.build_configuration.outputs.push_images == 'true'
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2
with:
registry: ${{ vars.REGISTRY_SERVER }}
username: ${{ vars.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and maybe push Proxy image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
with:
context: .
platforms: ${{ steps.build_configuration.outputs.platforms }}
push: ${{ steps.build_configuration.outputs.push_images == 'true' }}
build-args: |
KROXYLICIOUS_VERSION=${{ steps.build_configuration.outputs.release_version }}
tags: ${{ steps.build_configuration.outputs.proxy_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max,compression=zstd
- name: Build and maybe push Operator image
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
with:
context: .
file: ./Dockerfile.operator
platforms: ${{ steps.build_configuration.outputs.platforms }}
push: ${{ steps.build_configuration.outputs.push_images == 'true' }}
build-args: |
KROXYLICIOUS_VERSION=${{ steps.build_configuration.outputs.release_version }}
tags: ${{ steps.build_configuration.outputs.operator_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max,compression=zstd
- name: Slack Notification on Failure
if: failure() && env.SLACK_WEBHOOK_SET == 'true'
uses: ./.github/actions/common/slack-notification
with:
slackWebhook: ${{ secrets.KROXYLICIOUS_SLACK_WEBHOOK }}
slackTitle: 'Failure Alert: ${{ github.repository }}'
slackMessage: 'The docker build workflow failed on branch ${{ github.ref_name }}.'