Skip to content

Commit

Permalink
let GitHub Actions build & publish the Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Feb 21, 2025
1 parent c6ff432 commit cc7cb71
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: build & publish Docker image

on:
push:
branches:
- main

jobs:
build-publish:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: set up Docker buildx
uses: docker/setup-buildx-action@v3

- name: log into the GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: build and push Docker image
id: docker-build
uses: docker/build-push-action@v5
with:
tags: ghcr.io/${{ github.repository }}:ci
# labels: ${{ steps.docker-metadata.outputs.labels }}
# todo: add linux/arm64 once it is supported by the upstream/base image
platforms: linux/amd64
# https://docs.docker.com/build/ci/github-actions/cache/#cache-backend-api
cache-from: type=gha
cache-to: type=gha,mode=max

- name: compute Docker image tag
id: docker-tags
# We don't have upstream/base image's tag (or GeoServer version contained, which should be the same) available as a variables, so we must pull it from the image.
# todo: find a cleaner solution
run: |
set -e
set -x
echo '${{ toJSON(steps.docker-build.imageid) }}'# todo: remove
# https://stackoverflow.com/questions/1682442/reading-java-properties-file-from-bash#comment59733051_22857672
# https://stackoverflow.com/a/12524345/1072129
docker run --rm \
todo:ci \
/bin/cat \
/usr/local/tomcat/webapps/geoserver/META-INF/maven/org.geoserver.web/gs-web-app/pom.properties \
| sed '/^version=/!d; s///' | tr -d '\n'
# - name: build and push Docker image
# uses: docker/build-push-action@v5
# with:
# push: true
# tags: |
# ghcr.io/${{ github.repository }}:${{ steps.docker-tags.outputs.tag }}
# labels: ${{ steps.docker-metadata.outputs.labels }}
# platforms: linux/amd64
# # https://docs.docker.com/build/ci/github-actions/cache/#cache-backend-api
# cache-from: type=gha
# cache-to: type=gha,mode=max

0 comments on commit cc7cb71

Please sign in to comment.