Skip to content

Simplify GHA Docker publishing #39

Simplify GHA Docker publishing

Simplify GHA Docker publishing #39

name: Build Docker images
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published
jobs:
build:
name: Build and test Docker Image
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
axiom/docker-erddap
flavor: |
suffix=-jdk21-openjdk
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image
uses: docker/build-push-action@v6
with:
push: false
platforms: linux/amd64,linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
outputs: type=docker
- name: Run Docker Image in Background
run: docker run -d -p 8080:8080 ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Check that ERDDAP Docker Image will return a 200
uses: ifaxity/wait-on-action@v1
timeout-minutes: 1
with:
resource: http://localhost:8080/erddap/index.html
- name: Publish Docker images
if: |
((github.event_name == 'release' && github.event.action == 'published') || github.ref == 'refs/heads/main')
&& github.repository == 'axiom-data-science/docker-erddap'
uses: ./.github/actions/publish_docker_image