forked from artemiscloud/activemq-artemis-broker-image
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (116 loc) · 5.39 KB
/
update.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
name: Update
env:
IMAGE_NAME: activemq-artemis-broker
on:
workflow_dispatch:
inputs:
version:
description: 'Version, i.e. 1.0.0'
required: false
default: '*.*.+'
type: string
update_version:
description: 'Update version'
required: true
default: true
type: boolean
base_image:
description: 'Base image'
required: false
default: 'latest'
type: string
update_base_image:
description: 'Update base image'
required: true
default: true
type: boolean
activemq_artemis_version:
description: 'ActiveMQ Artemis version, i.e. 2.20.0'
required: false
default: 'latest'
type: string
update_activemq_artemis_version:
description: 'Update ActiveMQ Artemis version'
required: true
default: true
type: boolean
trigger_release:
description: 'Trigger release'
required: false
default: 'this'
type: choice
options:
- none
- this
- all
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Set up the repo
run: |
git config user.name 'artemiscloud-bot'
git config user.email '[email protected]'
git push
- name: Update version
if: ${{ inputs.update_version }}
run: |
CURRENT_VERSION=$(grep -m 1 -oP '(?<=^version: ")[^"]+' image.yaml)
IFS=. read CURRENT_VERSION_MAJOR CURRENT_VERSION_MINOR CURRENT_VERSION_PATCH <<< ${CURRENT_VERSION}
IFS=. read VERSION_MAJOR VERSION_MINOR VERSION_PATCH <<< ${{ inputs.version }}
VERSION_MAJOR=${VERSION_MAJOR/\*/${CURRENT_VERSION_MAJOR}} && VERSION_MAJOR=${VERSION_MAJOR/+/$((CURRENT_VERSION_MAJOR+1))}
VERSION_MINOR=${VERSION_MINOR/\*/${CURRENT_VERSION_MINOR}} && VERSION_MINOR=${VERSION_MINOR/+/$((CURRENT_VERSION_MINOR+1))}
VERSION_PATCH=${VERSION_PATCH/\*/${CURRENT_VERSION_PATCH}} && VERSION_PATCH=${VERSION_PATCH/+/$((CURRENT_VERSION_PATCH+1))}
VERSION="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
sed -i "s~^version:.*~version: \"${VERSION}\"~g" image.yaml
git commit --all --message "Update version to ${VERSION}" || echo "nothing to commit"
- name: Update base image
if: ${{ inputs.update_base_image }}
run: |
if [ "${{ inputs.base_image }}" = "latest" ]; then
BASE_IMAGE="registry.access.redhat.com/ubi8/openjdk-17@$(skopeo inspect docker://registry.access.redhat.com/ubi8/openjdk-17:latest | jq -r '.Digest')"
else
BASE_IMAGE="${{ inputs.base_image }}"
fi
sed -i "s~from.*~from: \"${BASE_IMAGE}\"~g" image.yaml
git commit --all --message "Update base image to ${BASE_IMAGE}" || echo "nothing to commit"
- name: Update ActiveMQ Artemis
if: ${{ inputs.update_activemq_artemis_version }}
run: |
if [ "${{ inputs.activemq_artemis_version }}" = "latest" ]; then
ACTIVEMQ_ARTEMIS_VERSION="$(curl https://activemq.apache.org/components/artemis/documentation/latest/index.html | grep -oP '(?<=Apache ActiveMQ Artemis )[0-9]+.[0-9]+.[0-9]+')"
else
ACTIVEMQ_ARTEMIS_VERSION="${{ inputs.activemq_artemis_version }}"
fi
APACHE_ARTEMIS_BIN_URL="https://archive.apache.org/dist/activemq/activemq-artemis/${ACTIVEMQ_ARTEMIS_VERSION}/apache-artemis-${ACTIVEMQ_ARTEMIS_VERSION}-bin.zip"
if ! wget -q --method=HEAD ${APACHE_ARTEMIS_BIN_URL}; then
APACHE_ARTEMIS_BIN_URL="https://www.apache.org/dyn/closer.cgi?filename=activemq/activemq-artemis/${ACTIVEMQ_ARTEMIS_VERSION}/apache-artemis-${ACTIVEMQ_ARTEMIS_VERSION}-bin.zip&action=download"
fi
wget -O apache-artemis-bin.zip ${APACHE_ARTEMIS_BIN_URL}
sed -i "/APACHE_ARTEMIS_VERSION/{n;s/value:.*/value: \"${ACTIVEMQ_ARTEMIS_VERSION}\"/}" modules/activemq-artemis-install/module.yaml
APACHE_ARTEMIS_BIN_MD5=($(md5sum apache-artemis-bin.zip))
PREV_APACHE_ARTEMIS_BIN_URL=$(sed -n '/name: apache-artemis-bin/,$p' modules/activemq-artemis-install/module.yaml | grep -Pom 1 'url:.*')
PREV_APACHE_ARTEMIS_BIN_MD5=$(sed -n '/name: apache-artemis-bin/,$p' modules/activemq-artemis-install/module.yaml | grep -Pom 1 'md5:.*')
sed -i -e "s~${PREV_APACHE_ARTEMIS_BIN_URL}~url: ${APACHE_ARTEMIS_BIN_URL}~" -e "s~${PREV_APACHE_ARTEMIS_BIN_MD5}~md5: ${APACHE_ARTEMIS_BIN_MD5}~" modules/activemq-artemis-install/module.yaml
git commit --all --message "Update ActiveMQ Artemis to ${ACTIVEMQ_ARTEMIS_VERSION}" || echo "nothing to commit"
- name: Push commits
run: |
git push
- name: Trigger release
if: ${{ inputs.trigger_release != 'none' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
const trigger_children = (context.payload.inputs.trigger_release === 'all' ? 'true' : 'false')
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'release.yml',
ref: context.ref,
inputs: {
trigger_children: trigger_children
}
});