-
Notifications
You must be signed in to change notification settings - Fork 18
151 lines (134 loc) · 6.04 KB
/
Copy pathci.yml
File metadata and controls
151 lines (134 loc) · 6.04 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CI
env:
IMAGE_NAME: arkmq-org-broker
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
types: [opened, edited, synchronize, reopened]
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
inputs:
snapshot:
description: 'Snapshot'
required: false
default: false
type: boolean
trigger_children:
description: 'Trigger children'
required: false
default: false
type: boolean
trigger_release:
description: 'Trigger release'
required: false
default: false
type: boolean
jobs:
validate:
name: Validate
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Validate commit messages
env:
COMMIT_COUNT: ${{ github.event.pull_request.commits }}
COMMIT_PATTERN: '^\[(NO-ISSUE|#[0-9]+)\] .+$'
run: |
git log --format=%s --max-count="$COMMIT_COUNT" --skip=1 | while IFS= read -r COMMIT_MESSAGE; do
if [[ ! "$COMMIT_MESSAGE" =~ $COMMIT_PATTERN ]]; then
echo "Invalid commit message: '$COMMIT_MESSAGE'"
echo "Commit messages must start with '[NO-ISSUE]' or '[#NNN]', followed by a space and a description."
exit 1
fi
done
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Install prerequisites
run: >
sudo apt-get update &&
sudo apt-get install gcc libkrb5-dev pass &&
sudo pip install cekit odcs[client]
- name: Checkout the repo
uses: actions/checkout@v7
- name: Update Apache Artemis
if: ${{ github.event_name == 'schedule' || inputs.snapshot }}
run: |
APACHE_ARTEMIS_VERSION=$(curl https://raw.githubusercontent.com/apache/artemis/main/pom.xml | grep -m 1 -oP '(?<=version>)[^<]+')
APACHE_ARTEMIS_SNAPSHOT_VERSION=$(curl https://repository.apache.org/content/repositories/snapshots/org/apache/artemis/apache-artemis/${APACHE_ARTEMIS_VERSION}/maven-metadata.xml | grep -m 1 -oP '(?<=value>)[^<]+')
APACHE_ARTEMIS_BIN_URL="https://repository.apache.org/content/repositories/snapshots/org/apache/artemis/apache-artemis/${APACHE_ARTEMIS_VERSION}/apache-artemis-${APACHE_ARTEMIS_SNAPSHOT_VERSION}-bin.zip"
wget -O apache-artemis-bin.zip ${APACHE_ARTEMIS_BIN_URL}
sed -i "/APACHE_ARTEMIS_VERSION/{n;s/value:.*/value: \"${APACHE_ARTEMIS_VERSION}\"/}" modules/apache-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/apache-artemis-install/module.yaml | grep -Pom 1 'url:.*')
PREV_APACHE_ARTEMIS_BIN_MD5=$(sed -n '/name: apache-artemis-bin/,$p' modules/apache-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/apache-artemis-install/module.yaml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build the image
run: |
cekit --verbose build --dry-run --overrides "{'labels': [{'name': 'git-sha', 'value': '$GITHUB_SHA'}]}" podman
podman build --platform linux/amd64 --platform linux/arm64 --manifest $IMAGE_NAME:dev.latest ./target/image
- name: Set up java
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
- name: Check the image
run: |
CONTAINER_ID=$(podman run --detach --network=host --env AMQ_USER=admin --env AMQ_PASSWORD=admin $IMAGE_NAME:dev.latest)
echo CONTAINER_ID=$CONTAINER_ID && sleep 3
CONTAINER_IP=$(hostname -I | cut -f 1 -d ' ')
echo CONTAINER_IP=$CONTAINER_IP
podman cp $CONTAINER_ID:/opt/amq ./
./amq/bin/artemis check queue --name TEST --produce 1000 --browse 1000 --consume 1000 --user admin --password admin --url tcp://$CONTAINER_IP:61616
podman kill $CONTAINER_ID
- name: Push the dev image
if: ${{ github.event_name == 'push' }}
run: |
podman login --username=${{ secrets.QUAY_USERNAME }} --password=${{ secrets.QUAY_PASSWORD }} quay.io
podman manifest push $IMAGE_NAME:dev.latest docker://quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME:dev.latest
- name: Push the snapshot image
if: ${{ github.event_name == 'schedule' || inputs.snapshot }}
run: |
podman login --username=${{ secrets.QUAY_USERNAME }} --password=${{ secrets.QUAY_PASSWORD }} quay.io
podman manifest push $IMAGE_NAME:dev.latest docker://quay.io/${{ secrets.QUAY_NAMESPACE }}/$IMAGE_NAME:snapshot
- name: Trigger children
if: ${{ github.event_name == 'schedule' || (inputs.trigger_children && !inputs.trigger_release) }}
uses: actions/github-script@v9
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: 'arkmq-org-broker-kubernetes-image',
workflow_id: 'ci.yml',
ref: context.ref,
inputs: {
snapshot: '${{ github.event_name == 'schedule' || inputs.snapshot }}',
trigger_children: 'true'
}
});
- name: Trigger release
if: ${{ inputs.trigger_release }}
uses: actions/github-script@v9
with:
github-token: ${{ secrets.BOT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.ref,
workflow_id: 'release.yml',
inputs: {
trigger_children: ${{ inputs.trigger_children }}
}
});