[#51] Migration of python scripts from version 2 to 3 #345
Workflow file for this run
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-kubernetes | |
S2I_RELEASE_URL: https://github.com/openshift/source-to-image/releases/download/v1.3.1/source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
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: > | |
mkdir -p $HOME/.local/bin && | |
echo "$HOME/.local/bin" >> $GITHUB_PATH && | |
sudo apt-get install gcc libkrb5-dev && | |
sudo pip install docker==5.0.3 docker-squash cekit odcs[client] packaging==21.3 behave lxml && | |
wget -O source-to-image.tar.gz $S2I_RELEASE_URL && | |
tar -C $HOME/.local/bin -xvf source-to-image.tar.gz | |
- name: Checkout the repo | |
uses: actions/checkout@v3 | |
- name: Update base image | |
if: ${{ inputs.snapshot }} | |
run: | | |
BASE_IMAGE="quay.io/${{ secrets.QUAY_NAMESPACE }}/activemq-artemis-broker@$(skopeo inspect docker://quay.io/${{ secrets.QUAY_NAMESPACE }}/activemq-artemis-broker:snapshot | jq -r '.Digest')" | |
sed -i "s~from.*~from: \"${BASE_IMAGE}\"~g" image.yaml | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- 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 --no-cache --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: ${{ inputs.trigger_children }} | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.BOT_TOKEN }} | |
script: | | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: context.repo.owner, | |
repo: 'activemq-artemis-broker-init-image', | |
workflow_id: 'ci.yml', | |
ref: 'main', | |
inputs: { | |
snapshot: '${{ inputs.snapshot }}', | |
trigger_children: 'true' | |
} | |
}); |