Skip to content

Commit

Permalink
replace dockerhub hooks with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mo3rfan committed Jun 28, 2024
1 parent 21049d8 commit 5f24a27
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 91 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Docker Image CI

on:
push:
branches: [ "main", '[0-9]+\.[0-9]+\.[0-9]+', '[0-9]+\.[0-9]+\.[x]' ]

env:
DOCKER_REPO: ${{ vars.DOCKER_REPO }}

jobs:
build_image:
runs-on: ubuntu-latest
steps:
- name: Validate build conditions
env:
NIGHTLY_MASTER_VERSION: ${{ vars.NIGHTLY_MASTER_VERSION }}
NIGHTLY_STABLE_VERSION: ${{ vars.NIGHTLY_STABLE_VERSION }}
NIGHTLY_MAINT_VERSION: ${{ vars.NIGHTLY_MAINT_VERSION }}
STABLE_VERSION: ${{ vars.STABLE_VERSION }}
MAINT_VERSION: ${{ vars.MAINT_VERSION }}
run: |
buildable_status=1
versions=("$NIGHTLY_MASTER_VERSION" "$NIGHTLY_STABLE_VERSION" "$NIGHTLY_MAINT_VERSION" "$STABLE_VERSION" "$MAINT_VERSION")
# We will proceed with the build only if the branch name is valid and supported by our repo-level vars.
for version in "${versions[@]}"; do
for single_version in $version; do
if [[ "$GITHUB_REF_NAME" == "$single_version" ]]; then
# Valid version
buildable_status=0
break;
fi
done
done
exit $buildable_status
- name: Initialise the cache for the plugin dependencies
id: plugincache
uses: actions/cache@v4
with:
path: ./resources/geoserver-plugins/
key: ${{ runner.os }}-build-${{ github.ref_name }}

- name: Download the dependencies (plugins)
if: steps.plugincache.outputs.cache-hit != 'true'
env:
PLUG_IN_LIST: "monitor control-flow libjpeg-turbo"
run: |
for version in $NIGHTLY_MASTER_VERSION; do
if [[ "$GITHUB_REF_NAME" == $version ]]; then
PLUG_IN_VERSION="2.$(expr $MIDDLE_STABLE + 1)-SNAPSHOT"
break
fi
done
if [ -z $PLUG_IN_VERSION ]; then
for version in $NIGHTLY_STABLE_VERSION; do
if [[ "$GITHUB_REF_NAME" == $version ]]; then
PLUG_IN_VERSION="2.$MIDDLE_STABLE-SNAPSHOT"
break
fi
done
fi
if [ -z $PLUG_IN_VERSION ]; then
for version in $NIGHTLY_MAINT_VERSION; do
if [[ "$GITHUB_REF_NAME" == $version ]]; then
PLUG_IN_VERSION="2.$(expr $MIDDLE_STABLE - 1)-SNAPSHOT"
break
fi
done
fi
if [ -z $PLUG_IN_VERSION ]; then
for version in $STABLE_VERSION $MAINT_VERSION; do
if [[ "$GITHUB_REF_NAME" == $version ]]; then
PLUG_IN_VERSION="$version"
break
fi
done
fi
mkdir -p ./resources/geoserver-plugins
for PLUG_IN_NAME in $PLUG_IN_LIST; do
URL="https://build.geoserver.org/geoserver/$GITHUB_REF_NAME/ext-latest/geoserver-$PLUG_IN_VERSION-$PLUG_IN_NAME-plugin.zip"
curl -C - -k -o ./resources/geoserver-plugins/geoserver-$PLUG_IN_VERSION-$PLUG_IN_NAME-plugin.zip $URL
done
- uses: actions/checkout@v4
- name: Build the geoserver image
run: |
WAR_FILE="https://build.geoserver.org/geoserver/$GITHUB_REF_NAME/geoserver-$GITHUB_REF_NAME-latest-war.zip"
docker build \
--build-arg GEOSERVER_WEBAPP_SRC="$WAR_FILE" \
--build-arg PLUG_IN_PATHS="./resources/geoserver-plugins" \
-f "$DOCKERFILE_PATH" \
-t "${DOCKER_REPO}:$GITHUB_REF_NAME" .
rm -rf ./resources/geoserver-plugins/*
- name: Login to docker hub
uses: docker/[email protected]
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Push docker image
run: docker push "${DOCKER_REPO}:$GITHUB_REF_NAME"

test:
runs-on: ubuntu-latest
needs: build_image
timeout-minutes: 10
steps:
- name: Run the tests
run: docker run --rm -i "${DOCKER_REPO}:$GITHUB_REF_NAME" /docker/tests/run_tests.sh
57 changes: 0 additions & 57 deletions hooks/build

This file was deleted.

23 changes: 0 additions & 23 deletions hooks/push

This file was deleted.

11 changes: 0 additions & 11 deletions hooks/test

This file was deleted.

0 comments on commit 5f24a27

Please sign in to comment.