Fix dict update of request headers (#460) #196
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
# Triggers a Docker workflow on push events and PRs but | |
# pushes to DockerHub only for push on the master branch. | |
# Runs GHC unit tests before DockerHub push. | |
# | |
# Author: Just van den Broecke - 2021 | |
# | |
name: Docker Build ⚓ | |
on: | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
paths-ignore: | |
- '**.md' | |
jobs: | |
# Single job now to build Docker Image, run GHC unit tests, and push to DockerHub | |
build_test_push: | |
name: Build, Test and Push Docker Image to DockerHub | |
runs-on: ubuntu-latest | |
# v2 https://github.com/docker/build-push-action/blob/master/UPGRADE.md | |
steps: | |
- name: Checkout ✅ | |
uses: actions/checkout@v2 | |
- name: Prepare 📦 | |
id: prep | |
run: | | |
DOCKER_IMAGE=geopython/geohealthcheck | |
VERSION=latest | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
if [[ $VERSION == master ]]; then | |
VERSION=latest | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
echo ::set-output name=image::${DOCKER_IMAGE} | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
- name: Show Image Settings 📦 | |
run: echo "IMAGE=${{ steps.prep.outputs.image }} VERSION=${{ steps.prep.outputs.version }} TAGS=${{ steps.prep.outputs.tags }}" | |
- name: Set up Docker Buildx 📦 | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub 📦 | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Docker Build only - retain local Image 📦 | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
load: true | |
push: false | |
tags: ${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
- name: GHC Unit Tests with Docker Image ⚙️ | |
run: docker run --entrypoint "/run-tests.sh" ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }} | |
- name: Push to Docker repo (on GH Push only) ☁️ | |
if: ${{ github.event_name == 'push' }} | |
run: docker push ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }} |