Update #184
This file contains hidden or 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: Update | |
| env: | |
| IMAGE_NAME: arkmq-org-broker | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| 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 | |
| apache_artemis_version: | |
| description: 'Apache Artemis version, i.e. 2.20.0' | |
| required: false | |
| default: 'latest' | |
| type: string | |
| update_apache_artemis_version: | |
| description: 'Update Apache 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@v7 | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Set up the repo | |
| run: | | |
| git config user.name 'arkmq-bot' | |
| git config user.email 'bot@arkmq.org' | |
| - name: Update base image | |
| id: update_base_image | |
| if: ${{ github.event_name == 'schedule' || inputs.update_base_image }} | |
| run: | | |
| if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ inputs.base_image }}" = "latest" ]; then | |
| BASE_IMAGE="registry.access.redhat.com/ubi9/openjdk-17@$(skopeo inspect docker://registry.access.redhat.com/ubi9/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 "[NO-ISSUE] Update base image to ${BASE_IMAGE}" && echo "status=DONE" >> $GITHUB_OUTPUT || echo "nothing to commit" | |
| - name: Update Apache Artemis | |
| id: update_apache_artemis_version | |
| if: ${{ github.event_name == 'schedule' || inputs.update_apache_artemis_version }} | |
| run: | | |
| if [ "${{ github.event_name }}" = "schedule" ] || [ "${{ inputs.apache_artemis_version }}" = "latest" ]; then | |
| APACHE_ARTEMIS_VERSION="$(curl https://artemis.apache.org/components/artemis/download/ | grep -oP '(?<=Apache Artemis )[0-9]+.[0-9]+.[0-9]+')" | |
| else | |
| APACHE_ARTEMIS_VERSION="${{ inputs.apache_artemis_version }}" | |
| fi | |
| APACHE_ARTEMIS_BIN_URL="https://archive.apache.org/dist/artemis/artemis/${APACHE_ARTEMIS_VERSION}/apache-artemis-${APACHE_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=artemis/artemis/${APACHE_ARTEMIS_VERSION}/apache-artemis-${APACHE_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: \"${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 | |
| git commit --all --message "[NO-ISSUE] Update Apache Artemis to ${APACHE_ARTEMIS_VERSION}" && echo "status=DONE" >> $GITHUB_OUTPUT || echo "nothing to commit" | |
| - name: Update version | |
| id: update_version | |
| if: ${{ (github.event_name == 'schedule' && steps.update_apache_artemis_version.outputs.status == 'DONE') || inputs.update_version }} | |
| env: | |
| UPDATE_VERSION: ${{ github.event_name == 'schedule' && '*.*.+' || inputs.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 <<< "${UPDATE_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 "[NO-ISSUE] Update version to ${VERSION}" && echo "status=DONE" >> $GITHUB_OUTPUT || echo "nothing to commit" | |
| - name: Push commits | |
| if: ${{ steps.update_version.outputs.status == 'DONE' || steps.update_base_image.outputs.status == 'DONE' || steps.update_apache_artemis_version.outputs.status == 'DONE' }} | |
| run: | | |
| git push | |
| - name: Trigger CI | |
| if: ${{ (github.event_name == 'schedule' && steps.update_apache_artemis_version.outputs.status == 'DONE') || inputs.trigger_release == 'this' || inputs.trigger_release == 'all' }} | |
| env: | |
| TRIGGER_CHILDREN: ${{ (github.event_name == 'schedule' && steps.update_apache_artemis_version.outputs.status == 'DONE') || inputs.trigger_release == 'all' }} | |
| 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: 'ci.yml', | |
| inputs: { | |
| trigger_children: process.env.TRIGGER_CHILDREN, | |
| trigger_release: true | |
| } | |
| }); |