mirror of
https://github.com/maplibre/martin.git
synced 2024-12-21 05:41:55 +03:00
86 lines
2.4 KiB
YAML
86 lines
2.4 KiB
YAML
name: Docker
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
release:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
docker:
|
|
# Don't change this name - it is used by the merge protection rules
|
|
name: Build and test docker image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
|
|
- name: Checkout sources
|
|
uses: actions/checkout@v3
|
|
|
|
# https://github.com/docker/metadata-action
|
|
- name: Docker meta
|
|
id: docker_meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: maplibre/martin
|
|
|
|
# https://github.com/docker/setup-qemu-action
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
# https://github.com/docker/setup-buildx-action
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
with:
|
|
install: true
|
|
|
|
- name: Build the Docker image
|
|
id: docker_build
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
push: false
|
|
load: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|
|
|
|
- name: Start postgres
|
|
uses: nyurik/action-setup-postgis@v1
|
|
id: pg
|
|
with:
|
|
username: test
|
|
password: test
|
|
database: test
|
|
rights: --superuser
|
|
|
|
- name: Init database
|
|
shell: bash
|
|
run: tests/fixtures/initdb.sh
|
|
env:
|
|
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
|
|
|
|
- name: Test Docker image
|
|
run: |
|
|
TAG=$(echo '${{ steps.docker_meta.outputs.tags }}' | cut -d' ' -f1)
|
|
export MARTIN_BUILD=-
|
|
export MARTIN_BIN="docker run --rm --net host -e DATABASE_URL -v $PWD/tests:/tests $TAG"
|
|
tests/test.sh
|
|
env:
|
|
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
if: ${{ github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork }}
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Push the Docker image
|
|
if: ${{ github.actor != 'dependabot[bot]' && github.event_name != 'pull_request' }}
|
|
uses: docker/build-push-action@v3
|
|
with:
|
|
push: true
|
|
tags: ${{ steps.docker_meta.outputs.tags }}
|
|
labels: ${{ steps.docker_meta.outputs.labels }}
|