forked from kroxylicious/kroxylicious
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (99 loc) · 4.77 KB
/
docker.yaml
File metadata and controls
111 lines (99 loc) · 4.77 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
# 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@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f
- name: Set up Java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '21'
- 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@c94ce9fb468520275223c153574b00df6fe4bcc9
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@263435318d21b8e681c14492fe198d362a7d2c83
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@263435318d21b8e681c14492fe198d362a7d2c83
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: rtCamp/action-slack-notify@e31e87e03dd19038e411e38ae27cbad084a90661 # v2
env:
SLACK_WEBHOOK: ${{ secrets.KROXYLICIOUS_SLACK_WEBHOOK }}
SLACK_COLOR: 'danger'
SLACK_TITLE: 'Failure Alert: ${{ github.repository }}'
SLACK_MESSAGE: 'The docker build workflow failed on branch ${{ github.ref_name }}.'