CI #620
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
env: | |
IMAGE_NAME: activemq-artemis-broker | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: '6 0 * * *' | |
workflow_dispatch: | |
inputs: | |
snapshot: | |
description: 'Snapshot' | |
required: false | |
default: false | |
type: boolean | |
trigger_children: | |
description: 'Trigger children' | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
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 docker==5.0.3 docker-squash cekit odcs[client] packaging==21.3 | |
- name: Checkout the repo | |
uses: actions/checkout@v4 | |
- name: Update ActiveMQ Artemis | |
if: ${{ github.event_name == 'schedule' || inputs.snapshot }} | |
run: | | |
ACTIVEMQ_ARTEMIS_VERSION=$(curl https://raw.githubusercontent.com/apache/activemq-artemis/main/pom.xml | grep -m 1 -oP '(?<=version>)[^<]+') | |
ACTIVEMQ_ARTEMIS_SNAPSHOT_VERSION=$(curl https://repository.apache.org/content/repositories/snapshots/org/apache/activemq/apache-artemis/${ACTIVEMQ_ARTEMIS_VERSION}/maven-metadata.xml | grep -m 1 -oP '(?<=value>)[^<]+') | |
APACHE_ARTEMIS_BIN_URL="https://repository.apache.org/content/repositories/snapshots/org/apache/activemq/apache-artemis/${ACTIVEMQ_ARTEMIS_VERSION}/apache-artemis-${ACTIVEMQ_ARTEMIS_SNAPSHOT_VERSION}-bin.zip" | |
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 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Build the image | |
run: | | |
cekit --verbose build --dry-run --overrides "{'labels': [{'name': 'quay.expires-after', 'value': '90d'}, {'name': 'git-sha', 'value': '$GITHUB_SHA'}]}" podman | |
podman build --platform linux/amd64 --platform linux/arm64 --manifest $IMAGE_NAME:dev.latest ./target/image | |
- 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: | | |
COMMIT_TAG=dev.$(date +%Y%m%d).$(git rev-parse --short "$GITHUB_SHA") | |
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:$COMMIT_TAG | |
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 }} | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.BOT_TOKEN }} | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: 'activemq-artemis-broker-kubernetes-image', | |
workflow_id: 'ci.yml', | |
ref: 'main', | |
inputs: { | |
snapshot: '${{ github.event_name == 'schedule' || inputs.snapshot }}', | |
trigger_children: 'true' | |
} | |
}); |