Skip to content

Commit a9aa89c

Browse files
committed
replace dockerhub hooks with github actions
1 parent 21049d8 commit a9aa89c

File tree

4 files changed

+117
-91
lines changed

4 files changed

+117
-91
lines changed

.github/workflows/build.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Docker Image CI
2+
3+
on:
4+
push:
5+
branches: [ "main", '[0-9]+\.[0-9]+\.[0-9]+', '[0-9]+\.[0-9]+\.[x]' ]
6+
7+
env:
8+
DOCKER_REPO: ${{ vars.DOCKER_REPO }}
9+
10+
jobs:
11+
build_image:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Validate build conditions
15+
env:
16+
NIGHTLY_MASTER_VERSION: ${{ vars.NIGHTLY_MASTER_VERSION }}
17+
NIGHTLY_STABLE_VERSION: ${{ vars.NIGHTLY_STABLE_VERSION }}
18+
NIGHTLY_MAINT_VERSION: ${{ vars.NIGHTLY_MAINT_VERSION }}
19+
STABLE_VERSION: ${{ vars.STABLE_VERSION }}
20+
MAINT_VERSION: ${{ vars.MAINT_VERSION }}
21+
run: |
22+
buildable_status=1
23+
versions=("$NIGHTLY_MASTER_VERSION" "$NIGHTLY_STABLE_VERSION" "$NIGHTLY_MAINT_VERSION" "$STABLE_VERSION" "$MAINT_VERSION")
24+
# We will proceed with the build only if the branch name is valid and supported by our repo-level vars.
25+
for version in "${versions[@]}"; do
26+
for single_version in $version; do
27+
if [[ "$GITHUB_REF_NAME" == "$single_version" ]]; then
28+
# Valid version
29+
buildable_status=0
30+
break;
31+
fi
32+
done
33+
done
34+
exit $buildable_status
35+
36+
- name: Initialise the cache for the plugin dependencies
37+
id: plugincache
38+
uses: actions/cache@v4
39+
with:
40+
path: ./resources/geoserver-plugins/
41+
key: ${{ runner.os }}-build-${{ github.ref_name }}
42+
43+
- name: Download the dependencies (plugins)
44+
if: steps.plugincache.outputs.cache-hit != 'true'
45+
env:
46+
PLUG_IN_LIST: "monitor control-flow libjpeg-turbo"
47+
NIGHTLY_MASTER_VERSION: ${{ vars.NIGHTLY_MASTER_VERSION }}
48+
NIGHTLY_STABLE_VERSION: ${{ vars.NIGHTLY_STABLE_VERSION }}
49+
NIGHTLY_MAINT_VERSION: ${{ vars.NIGHTLY_MAINT_VERSION }}
50+
STABLE_VERSION: ${{ vars.STABLE_VERSION }}
51+
MAINT_VERSION: ${{ vars.MAINT_VERSION }}
52+
run: |
53+
for version in $NIGHTLY_MASTER_VERSION; do
54+
if [[ "$GITHUB_REF_NAME" == $version ]]; then
55+
PLUG_IN_VERSION="2.$(expr $MIDDLE_STABLE + 1)-SNAPSHOT"
56+
break
57+
fi
58+
done
59+
if [ -z $PLUG_IN_VERSION ]; then
60+
for version in $NIGHTLY_STABLE_VERSION; do
61+
if [[ "$GITHUB_REF_NAME" == $version ]]; then
62+
PLUG_IN_VERSION="2.$MIDDLE_STABLE-SNAPSHOT"
63+
break
64+
fi
65+
done
66+
fi
67+
if [ -z $PLUG_IN_VERSION ]; then
68+
for version in $NIGHTLY_MAINT_VERSION; do
69+
if [[ "$GITHUB_REF_NAME" == $version ]]; then
70+
PLUG_IN_VERSION="2.$(expr $MIDDLE_STABLE - 1)-SNAPSHOT"
71+
break
72+
fi
73+
done
74+
fi
75+
76+
if [ -z $PLUG_IN_VERSION ]; then
77+
for version in $STABLE_VERSION $MAINT_VERSION; do
78+
if [[ "$GITHUB_REF_NAME" == $version ]]; then
79+
PLUG_IN_VERSION="$version"
80+
break
81+
fi
82+
done
83+
fi
84+
85+
mkdir -p ./resources/geoserver-plugins
86+
for PLUG_IN_NAME in $PLUG_IN_LIST; do
87+
URL="https://build.geoserver.org/geoserver/$GITHUB_REF_NAME/ext-latest/geoserver-$PLUG_IN_VERSION-$PLUG_IN_NAME-plugin.zip"
88+
curl -C - -k -o ./resources/geoserver-plugins/geoserver-$PLUG_IN_VERSION-$PLUG_IN_NAME-plugin.zip $URL
89+
done
90+
91+
- uses: actions/checkout@v4
92+
- name: Build the geoserver image
93+
run: |
94+
WAR_FILE="https://build.geoserver.org/geoserver/$GITHUB_REF_NAME/geoserver-$GITHUB_REF_NAME-latest-war.zip"
95+
docker build \
96+
--build-arg GEOSERVER_WEBAPP_SRC="$WAR_FILE" \
97+
--build-arg PLUG_IN_PATHS="./resources/geoserver-plugins" \
98+
-f "$DOCKERFILE_PATH" \
99+
-t "${DOCKER_REPO}:$GITHUB_REF_NAME" .
100+
rm -rf ./resources/geoserver-plugins/*
101+
102+
- name: Login to docker hub
103+
uses: docker/[email protected]
104+
with:
105+
username: ${{ secrets.REGISTRY_USERNAME }}
106+
password: ${{ secrets.REGISTRY_PASSWORD }}
107+
108+
- name: Push docker image
109+
run: docker push "${DOCKER_REPO}:$GITHUB_REF_NAME"
110+
111+
test:
112+
runs-on: ubuntu-latest
113+
needs: build_image
114+
timeout-minutes: 10
115+
steps:
116+
- name: Run the tests
117+
run: docker run --rm -i "${DOCKER_REPO}:$GITHUB_REF_NAME" /docker/tests/run_tests.sh

hooks/build

Lines changed: 0 additions & 57 deletions
This file was deleted.

hooks/push

Lines changed: 0 additions & 23 deletions
This file was deleted.

hooks/test

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)