Auto build QGIS server Docker images #870
This file contains 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: Auto build QGIS server Docker images | |
on: | |
schedule: | |
# runs once a week | |
- cron: '0 6 * * 0' | |
# runs every day | |
# - cron: '0 6 * * *' | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
DEFAULT_UBUNTU_RELEASE: noble # for the default dist, no suffix to tag | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
jobs: | |
build-nightly: | |
runs-on: ubuntu-latest | |
name: build nightly | |
strategy: | |
fail-fast: false | |
matrix: | |
qgis_type: [ 'desktop', 'server' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: gautamkrishnar/keepalive-workflow@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: define tag | |
run: | | |
echo "DOCKER_TAG=$( [[ ${{ matrix.qgis_type }} = 'server' ]] && echo 'qgis-server' || echo 'qgis' )" >> $GITHUB_ENV | |
- id: nightly | |
name: building nightly | |
run: docker build -t qgis/${{ env.DOCKER_TAG }}:nightly --build-arg repo=ubuntu-nightly -f ${{ matrix.qgis_type }}/Dockerfile . | |
- name: test | |
if: ${{ matrix.qgis_type == 'server' }} | |
run: | | |
docker run -d -v $(pwd)/${{ matrix.qgis_type }}/test/data:/io/data -p 8010:80 --name qgis-server qgis/qgis-server:nightly | |
docker exec -i qgis-server dpkg -l qgis-server | |
sleep 5 | |
curl -s 'http://localhost:8010/ogc/test_project?service=WMS&request=GetCapabilities' | grep -ivq exception | |
- name: push | |
if: ${{ github.event_name != 'pull_request' }} | |
run: | | |
docker push qgis/${{ env.DOCKER_TAG }}:nightly | |
docker tag qgis/${{ env.DOCKER_TAG }}:nightly qgis/${{ env.DOCKER_TAG }}:latest | |
docker push qgis/${{ env.DOCKER_TAG }}:latest | |
build: | |
if: ${{ github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
name: build | |
strategy: | |
fail-fast: false | |
matrix: | |
qgis_type: ['desktop', 'server'] | |
version: ['stable', 'ltr'] | |
platform: | |
- os: ubuntu | |
release: jammy | |
- os: ubuntu | |
release: noble | |
- os: debian | |
release: bookworm | |
steps: | |
- uses: actions/checkout@v4 | |
- id: python_deps | |
run: pip3 install packaging | |
- id: determine | |
name: determine QGIS and Docker versions | |
env: | |
GITHUB_EVENT_NAME: ${{ github.event_name }} | |
run : | | |
DOCKER=$(./scripts/get_docker_image_version.py --qgis=${{ matrix.qgis_type }} --dist=${{ matrix.platform.release }}) | |
QGIS=$(./scripts/get_ubuntu_qgis_package_version.py --qgis=${{ matrix.qgis_type }} --os=${{ matrix.platform.os }} --dist ${{ matrix.platform.release }}) | |
DOCKER_VERSION=$(echo "${DOCKER}" | jq ".${{ matrix.version }}") | |
QGIS_VERSION=$(echo "${QGIS}" | jq ".${{ matrix.version }}") | |
echo "Existing ${{ matrix.version }} docker: ${DOCKER_VERSION}" | |
echo "Available ${{ matrix.version }} QGIS: ${QGIS_VERSION}" | |
WILL_UPDATE=$(python3 -c "from packaging import version; print(1 if version.parse(${DOCKER_VERSION} or '0') < version.parse(${QGIS_VERSION}) else 0)") | |
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then | |
echo "Force build on workflow dispatch." | |
WILL_UPDATE=1 | |
fi | |
if [[ ${WILL_UPDATE} == 1 ]]; then | |
echo "--> ${{ matrix.version }} will be updated from ${DOCKER_VERSION} to ${QGIS_VERSION}." | |
else | |
echo "--> ${{ matrix.version }} is up to date (${QGIS_VERSION})." | |
fi | |
echo "will_update=${WILL_UPDATE}" >> $GITHUB_OUTPUT | |
echo "qgis_version=${QGIS_VERSION//\"/}">> $GITHUB_OUTPUT | |
- name: Set up QEMU | |
if: ${{ steps.determine.outputs.will_update == 1 }} | |
uses: docker/setup-qemu-action@v3 | |
with: | |
image: tonistiigi/binfmt:latest | |
platforms: arm64,arm | |
- name: Set up Docker Buildx | |
if: ${{ steps.determine.outputs.will_update == 1 }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: ${{ steps.determine.outputs.will_update == 1 }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- id: build | |
if: ${{ steps.determine.outputs.will_update == 1 }} | |
name: build ubuntu image | |
env: | |
DOCKER_USERNAME: ${{ secrets.docker_username }} | |
DOCKER_PASSWORD: ${{ secrets.docker_password }} | |
run: ./scripts/build-push-docker.sh ${{ matrix.qgis_type }} ${{ matrix.version }} ${{steps.determine.outputs.qgis_version}} ${{ matrix.platform.os }} ${{ matrix.platform.release }} ${DEFAULT_UBUNTU_RELEASE} |