forked from strimzi/strimzi-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (69 loc) · 2.85 KB
/
ci-workflow.yml
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
name: CI Workflow - Build Docker Images
# CI is applied to every push event to any branch,
# except for the upstream branch that is auto-tracking the original Strimzi repository.
on:
push:
branches-ignore:
- upstream
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Determine checkout ref based on event
id: set_checkout_ref
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "checkout_ref=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
else
echo "checkout_ref=${{ github.ref }}" >> $GITHUB_OUTPUT
fi
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ steps.set_checkout_ref.outputs.checkout_ref }}
- name: Set up Java 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: maven
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn -B -V -e -Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true clean install
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Maven Build and Install JAR files
working-directory: docker-images/artifacts
run: make java_install
- name: Build Docker Images
working-directory: docker-images
run: make docker_build
- name: Determine Image Tag
id: image_tags
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# For tag push events, use the git tag as the image tag.
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "Detected tag push: $TAG_NAME"
echo "IMAGE_TAG=ghcr.io/${GITHUB_REPOSITORY_OWNER}/strimzi-kafka-operator:${TAG_NAME}" >> $GITHUB_OUTPUT
elif [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
# For pull requests, use the commit SHA.
echo "Detected pull_request event"
echo "IMAGE_TAG=ghcr.io/${GITHUB_REPOSITORY_OWNER}/strimzi-kafka-operator:${GITHUB_SHA}" >> $GITHUB_OUTPUT
else
# For branch pushes, use the commit SHA.
echo "Detected branch push: ${GITHUB_REF}"
echo "IMAGE_TAG=ghcr.io/${GITHUB_REPOSITORY_OWNER}/strimzi-kafka-operator:${GITHUB_SHA}" >> $GITHUB_OUTPUT
fi
- name: Build Docker Image (CI Only)
uses: docker/build-push-action@v3
with:
context: ./docker-images
push: false
tags: ${{ steps.image_tags.outputs.IMAGE_TAG }}