-
Notifications
You must be signed in to change notification settings - Fork 82
130 lines (127 loc) · 5.99 KB
/
check-base-images.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
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
name: Check base images
on:
workflow_dispatch:
inputs:
MINIMAL_SUPPORTED_VERSION:
description: 'Minimal supported version from which we should start checking images, e.g. 5.1, 5.0.1, 4.2.3. Default values is 5.2'
required: false
schedule:
- cron: '0 6 * * *'
jobs:
get-latest-patch-versions:
runs-on: ubuntu-latest
name: Get latest patch versions
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
MINIMAL_SUPPORTED_VERSION: ${{ github.event.inputs.MINIMAL_SUPPORTED_VERSION }}
DEFAULT_MINIMAL_SUPPORTED_VERSION: 5.2
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: set-matrix
name: Get latest patch versions
run: |
. .github/scripts/version.functions.sh
MIN_VERSION=${MINIMAL_SUPPORTED_VERSION:-$DEFAULT_MINIMAL_SUPPORTED_VERSION}
echo "Getting latest patch versions starting from $MIN_VERSION"
versions=$(printf '%s\n' $(get_latest_patch_versions "${MIN_VERSION}") | jq -R . | jq -c -s .)
echo "Found latest patch versions: $versions"
echo "matrix={\"version\":$versions}" >> $GITHUB_OUTPUT
- name: Slack notification
uses: ./.github/actions/slack-notification
if: failure()
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }}
trigger-rebuilds:
runs-on: ubuntu-latest
name: Rebuild ${{ matrix.version }} if base image changed
needs: get-latest-patch-versions
env:
NLC_REPOSITORY: ${{ secrets.NLC_REPOSITORY }}
NLC_REPO_USERNAME: ${{ secrets.NLC_REPO_USERNAME }}
NLC_REPO_TOKEN: ${{ secrets.NLC_REPO_TOKEN }}
NLC_IMAGE_NAME: ${{ secrets.NLC_IMAGE_NAME }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.get-latest-patch-versions.outputs.matrix) }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Checkout version ${{ matrix.version }}
uses: actions/checkout@v4
with:
ref: v${{ matrix.version }}
path: v${{ matrix.version }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Login to NLC Docker Repository
run: echo "${NLC_REPO_TOKEN}" | docker login -u ${NLC_REPO_USERNAME} ${NLC_REPOSITORY} --password-stdin
- name: Check if ${{ matrix.version }} base images updated
run: |
. .github/scripts/base-image-updated.sh
. .github/scripts/packages-updated.sh
. .github/scripts/log.functions.sh
echo "Checking OSS ${{ matrix.version }} image"
if base_image_updated hazelcast/hazelcast:${{ matrix.version }} v${{ matrix.version }}/hazelcast-oss/Dockerfile; then
echo "OSS_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "Image OSS ${{ matrix.version }} needs rebuild"
else
log_info "Image OSS ${{ matrix.version }} is up-to-date"
fi
echo "Checking system package upgrades for OSS ${{ matrix.version }} image"
if packages_updated_oss hazelcast/hazelcast:${{ matrix.version }}; then
echo "OSS_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "System package upgrades for OSS ${{ matrix.version }} image available"
else
log_info "System packages for OSS ${{ matrix.version }} image are up-to-date"
fi
echo "Checking EE ${{ matrix.version }} image"
if base_image_updated hazelcast/hazelcast-enterprise:${{ matrix.version }} v${{ matrix.version }}/hazelcast-enterprise/Dockerfile; then
echo "EE_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "Image EE ${{ matrix.version }} needs rebuild"
else
log_info "Image EE ${{ matrix.version }} is up-to-date"
fi
echo "Checking system package upgrades for EE ${{ matrix.version }} image"
if packages_updated_ee hazelcast/hazelcast-enterprise:${{ matrix.version }}; then
echo "EE_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "System package upgrades for EE ${{ matrix.version }} image available"
else
log_info "System packages for EE ${{ matrix.version }} image are up-to-date"
fi
echo "Checking EE NLC ${{ matrix.version }} image"
if base_image_updated ${NLC_IMAGE_NAME}:${{ matrix.version }} v${{ matrix.version }}/hazelcast-enterprise/Dockerfile; then
echo "EE_NLC_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "Image EE NLC ${{ matrix.version }} needs rebuild"
else
log_info "Image EE NLC ${{ matrix.version }} is up-to-date"
fi
echo "Checking system package upgrades for EE NLC ${{ matrix.version }} image"
if packages_updated_ee ${NLC_IMAGE_NAME}:${{ matrix.version }}; then
echo "EE_NLC_NEEDS_REBUILD=yes" >> $GITHUB_ENV
log_info "System package upgrades for EE NLC ${{ matrix.version }} image available"
else
log_info "System packages for EE NLC ${{ matrix.version }} image are up-to-date"
fi
- name: Rebuild ${{ matrix.version }} EE image
if: env.EE_NEEDS_REBUILD == 'yes'
run: |
echo "Rebuilding ${{ matrix.version }} EE image"
gh workflow run tag_image_push.yml --ref v${{ matrix.version }} -f HZ_VERSION=${{ matrix.version }} -f RELEASE_TYPE=EE
gh workflow run tag_image_push_rhel.yml --ref v${{ matrix.version }} -f HZ_VERSION=${{ matrix.version }}
env:
GH_TOKEN: ${{ github.token }}
- name: Rebuild ${{ matrix.version }} EE NLC image
if: env.EE_NLC_NEEDS_REBUILD == 'yes'
run: |
echo "Rebuilding ${{ matrix.version }} EE NLC image"
gh workflow run ee-nlc-tag-push.yml --ref v${{ matrix.version }} -f HZ_VERSION=${{ matrix.version }}
env:
GH_TOKEN: ${{ github.token }}
- name: Slack notification
uses: ./.github/actions/slack-notification
if: failure()
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK }}