Enhanced testing #29
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: Publish to DockerHub | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
branches: | |
- 'main' | |
release: | |
types: [created] | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
outputs: | |
tags: ${{ steps.meta.outputs.tags }} | |
version: ${{ steps.meta.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: communityfirst/mbgl-tile-renderer | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Docker Hub Description | |
if: github.event_name == 'release' | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: communityfirst/mbgl-tile-renderer | |
short-description: 'Node.js MapGL renderer for styled raster tiles in MBTiles format.' | |
test: | |
needs: docker | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- style: self | |
command: "--style self --stylelocation tests/fixtures/alert/style-with-geojson.json --stylesources tests/fixtures/alert/sources" | |
- style: bing | |
command: "--style bing" | |
- style: esri | |
command: "--style esri --overlay '{\"type\": \"FeatureCollection\", \"name\": \"alert\", \"features\": [{\"geometry\": {\"coordinates\": [[[-54.25348208981326, 3.140689896338671], [-54.25348208981326, 3.140600064810259], [-54.253841415926914, 3.140600064810259], [-54.25348208981326, 3.140689896338671]]], \"geodesic\": false, \"type\": \"Polygon\"}, \"id\": \"-603946+34961\", \"properties\": {\"month_detec\": \"09\", \"year_detec\": \"2023\"}, \"type\": \"Feature\"}]}'" | |
- style: mapbox | |
command: "--style mapbox --mapboxstyle mapbox-style-placeholder --apikey mapbox-api-key-placeholder" | |
- style: planet | |
command: "--style planet --monthyear 2013-12 --apikey planet-api-key-placeholder" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Test run of Docker image with ${{ matrix.style }} style | |
env: | |
MAPBOX_STYLE: ${{ secrets.MAPBOX_STYLE }} | |
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }} | |
PLANET_API_KEY: ${{ secrets.PLANET_API_KEY }} | |
run: | | |
docker run --rm -v ${{ github.workspace }}/outputs:/app/outputs ${{ needs.docker.outputs.tags }} -s ${{ matrix.command }} --bounds "-54.28772,3.11460,-54.03630,3.35025" -Z ${{ matrix.style == 'planet' && '5' || '10' }} -o ${{ matrix.style }}-${{ needs.docker.outputs.version }} | |
- name: Upload mbtiles artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: mbtiles-${{ needs.docker.outputs.version }} | |
path: outputs/*.mbtiles | |
if-no-files-found: error # 'warn' or 'ignore' are also available, 'error' will fail the step | |
retention-days: ${{ github.event_name == 'release' && 90 || 15 }} |