Skip to content

deploy-image

deploy-image #211

Workflow file for this run

name: deploy-image
on:
workflow_dispatch:
workflow_run:
workflows:
- build-latest
branches:
- 2.28.5
types:
- completed
#permissions:
# contents: read
jobs:
deploy-image:
#if: |
#github.actor != 'dependabot[bot]' &&
#!(
#contains(github.event.pull_request.title, '[skip-release]') ||
#contains(github.event.comment.body, '/skiprelease')
#) && github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
timeout-minutes: 45
env:
latest-ref: refs/heads/2.28.5
strategy:
matrix:
stablePluginBaseURL:
# empty because it often changes, so it's better
# to use the default one described in the Dockerfile
# to make it consistent. How-ever we keep this in GH Action
# to make it easy to pass overrides in the future.
- https://sourceforge.net/projects/geoserver/files/GeoServer
geoserverPatchMajorVersionBugs:
# useful to also update existing broken image, defaults to no
- no
steps:
- uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to DockerHub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Check latest GeoServer version
id: geoserver_check
shell: bash
run: |
IMAGE_VERSION=3.12-slim
docker run --rm \
-v "$PWD/.github/workflows/scripts:/scripts" \
-v "$GITHUB_OUTPUT:/github_output/github_output.txt" \
python:${IMAGE_VERSION} \
bash /scripts/check_geoserver_version.sh
- name: Check tomcat version in the series
id: tomcat_check
shell: bash
run: |
IMAGE_VERSION=3.12-slim
docker run --rm \
-v "$PWD/.github/workflows/scripts:/scripts" \
-v "$GITHUB_OUTPUT:/github_output/github_output.txt" \
python:${IMAGE_VERSION} \
bash /scripts/check_tomcat_version.sh
- name: Check Java Home path
id: java_home_check
shell: bash
run: |
IMAGE_VERSION=${{ steps.tomcat_check.outputs.tomcat_version }}
JAVA_HOME=$(
docker run --rm \
"tomcat:${IMAGE_VERSION}" \
sh -c 'printf "%s" "$JAVA_HOME"'
)
echo "${JAVA_HOME}"
echo "java_home=${JAVA_HOME}" >> $GITHUB_OUTPUT
- name: Check GDAL version
id: gdal_version_check
shell: bash
run: |
IMAGE_VERSION=${{ steps.tomcat_check.outputs.tomcat_version }}
docker run --rm \
-v "$PWD/.github/workflows/scripts:/scripts" \
-v "$GITHUB_OUTPUT:/github_output/github_output.txt" \
tomcat:${IMAGE_VERSION} \
bash /scripts/get_gdal_version.sh
- name: Tomcat Digest for image used in build
id: tomcat_digest
shell: bash
run: |
PUBLISHED_TOMCAT="${{ steps.tomcat_check.outputs.tomcat_version }}"
TOMCAT_DIGEST=$(docker inspect \
--format='{{index .RepoDigests 0}}' \
tomcat:${PUBLISHED_TOMCAT})
echo "${TOMCAT_DIGEST}"
echo "tomcat_sha=${TOMCAT_DIGEST}" >> $GITHUB_OUTPUT
- name: Get Current Date
id: current_date
run: echo "formatted=$(date -u +%Y.%m.%d)" >> $GITHUB_OUTPUT
- name: Check if image exists on Docker Hub
id: check_hub_image_exists
shell: bash
run: |
set -e
status=$(curl -s -o /dev/null -w "%{http_code}" \
https://hub.docker.com/v2/repositories/kartoza/geoserver/tags/${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}/
)
echo "check_image=$status" >> "$GITHUB_OUTPUT"
- name: Build prod image
if: |
github.actor != 'dependabot[bot]' &&
!(
contains(github.event.pull_request.title, '[skip-release]') ||
contains(github.event.comment.body, '/skiprelease')
) && github.event.workflow_run.conclusion == 'success'
timeout-minutes: 45
id: docker_build_prod
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
push: true
tags: |
${{ ( steps.check_hub_image_exists.outputs.check_image != 200 || matrix.geoserverPatchMajorVersionBugs == 'yes' ) && format('{0}/geoserver:{1}.{2}.{3}', secrets.DOCKERHUB_REPO, steps.geoserver_check.outputs.major, steps.geoserver_check.outputs.minor, steps.geoserver_check.outputs.bugfix) || null}}
${{ secrets.DOCKERHUB_REPO }}/geoserver:${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}
${{ secrets.DOCKERHUB_REPO }}/geoserver:${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}--v${{ steps.current_date.outputs.formatted }}
build-args: |
IMAGE_VERSION=${{ steps.tomcat_check.outputs.tomcat_version }}
JAVA_HOME=${{ steps.java_home_check.outputs.java_home }}
GS_VERSION=${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}
WAR_URL=https://downloads.sourceforge.net/project/geoserver/GeoServer/${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}/geoserver-${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}-war.zip
STABLE_PLUGIN_BASE_URL=${{ matrix.stablePluginBaseURL }}
GDAL_VERSION=${{ steps.gdal_version_check.outputs.gdal_version }}
TOMCAT_IMAGE_SHA=${{ steps.tomcat_digest.outputs.tomcat_sha }}
cache-from: |
type=gha,scope=prod
target: geoserver-prod
publish_release_artifacts:
runs-on: ubuntu-latest
timeout-minutes: 15
if: |
github.actor != 'dependabot[bot]' &&
!(
contains(github.event.pull_request.title, '[skip-release]') ||
contains(github.event.comment.body, '/skiprelease')
) && github.event.workflow_run.conclusion == 'success'
needs: [deploy-image]
steps:
- name: Checkout code
id: git_checkout
uses: actions/checkout@v6
with:
ref: '2.28.5'
- name: Get Current Date
id: current_date
run: echo "formatted=$(date -u +%Y.%m.%d)" >> $GITHUB_OUTPUT
- name: Check latest GeoServer version
id: geoserver_check
shell: bash
run: |
docker run --rm \
-v "$PWD/.github/workflows/scripts:/scripts" \
-v "$GITHUB_OUTPUT:/github_output/github_output.txt" \
python:3.12-slim \
bash /scripts/check_geoserver_version.sh
- name: Get Latest Commit Hash
id: latest_commit_hash
run: echo "commit=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
- name: publish_release
id: tag_releases
run: |
gh release create v${{ steps.geoserver_check.outputs.major }}.${{ steps.geoserver_check.outputs.minor }}.${{ steps.geoserver_check.outputs.bugfix }}--${{ steps.current_date.outputs.formatted }}--${{ steps.latest_commit_hash.outputs.commit }} --notes ${{ steps.latest_commit_hash.outputs.commit }} --target 2.28.5 --repo $GITHUB_REPOSITORY
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}