Skip to content

#28230 include in 23.10.24 #2290

#28230 include in 23.10.24

#28230 include in 23.10.24 #2290

name: Build/Push dotCMS docker image (on release)
on:
push:
branches:
- release-*
repository_dispatch:
types:
- enterprise-update
jobs:
publish_image:
name: Publish DotCMS docker image on release push
runs-on: ubuntu-20.04
steps:
- name: Process Params
run: |
if [[ "${{ github.event_name }}" == 'repository_dispatch' ]]; then
BUILD_ID=${{ github.event.client_payload.build_id }}
else
BUILD_ID=$(basename "${{ github.ref }}")
fi
if [[ -z "${BUILD_ID}" ]]; then
echo 'Could not resolve BUILD_ID, aborting'
exit 1
else
echo "Found BUILD_ID: ${BUILD_ID}"
fi
echo "BUILD_ID=${BUILD_ID}" >> $GITHUB_ENV
- name: Checkout core
uses: actions/checkout@v4
with:
ref: ${{ env.BUILD_ID }}
- uses: ./.github/actions/cleanup-runner
- name: Set Common Vars
run: |
BUILD_HASH=$(git log -1 --pretty=%h)
BUILD_HASH=${BUILD_HASH::7}
eval $(cat dotCMS/gradle.properties| grep dotcmsReleaseVersion)
DOTCMS_VERSION="${dotcmsReleaseVersion}"
if [[ ${BUILD_ID} =~ ^release-[0-9]{2}.[0-9]{2}(.[0-9]{1,2})?_lts$ ]]; then
jobRun=true
else
jobRun=false
fi
echo "BUILD_HASH=${BUILD_HASH}" >> $GITHUB_ENV
echo "DOTCMS_VERSION=${DOTCMS_VERSION}" >> $GITHUB_ENV
echo "jobRun=${jobRun}" >> $GITHUB_ENV
- name: Discover docker tags
id: discover-docker-tags
uses: dotcms/discover-docker-tags-action@v2.0
with:
version: ${{ env.DOTCMS_VERSION }}
hash: ${{ env.BUILD_HASH }}
label: 'SNAPSHOT'
update_stable: false
also_latest: false
image_name: dotcms/dotcms
if: env.jobRun == 'true'
- name: Format docker tags
id: format-docker-tags
run: |
tags=${{ steps.discover-docker-tags.outputs.discovered_tags }}
sep=
formatted=
for tag in ${tags//,/ }
do
formatted="$formatted$sep\`$tag\`"
[[ -z "$sep" ]] && sep=', '
done
echo "discovered_tags=${formatted}" >> $GITHUB_OUTPUT
if: env.jobRun == 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
with:
platforms: amd64,arm64
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v3.0.0
with:
platforms: linux/amd64,linux/arm64
driver-opts: |
image=moby/buildkit:v0.12.2
- name: Docker Hub login
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Pre build
run: |
docker system prune --volumes -af
- name: Build and push
uses: docker/build-push-action@v5.0.0
with:
context: ./docker/dotcms
push: true
tags: ${{ steps.discover-docker-tags.outputs.discovered_tags }}_SNAPSHOT
platforms: linux/amd64,linux/arm64
build-args: |
BUILD_FROM=COMMIT
BUILD_ID=${{ env.BUILD_ID }}
if: env.jobRun == 'true'
# - name: Slack Notification
# if: success() && env.jobRun == 'true'
# uses: rtCamp/action-slack-notify@v2
# env:
# SLACK_WEBHOOK: ${{ secrets.DEVELOPERS_SLACK_WEBHOOK }}
# SLACK_USERNAME: dotBot
# SLACK_TITLE: "Attention dotters: Docker image built!"
# SLACK_MSG_AUTHOR: " "
# MSG_MINIMAL: true
# SLACK_FOOTER: ""
# SLACK_ICON: https://avatars.githubusercontent.com/u/1005263?s=200&v=4
# SLACK_MESSAGE: "<!channel> This automated script is happy to announce that a new docker image has been built for *${{ env.DOTCMS_VERSION }}* with tag: ${{ steps.format-docker-tags.outputs.discovered_tags }} :docker:"