Skip to content

[122] Update api service libraries (#137) #11

[122] Update api service libraries (#137)

[122] Update api service libraries (#137) #11

name: Geocoding Service Github Packages Push
on:
# Build whenever a PR is merged into the main branch.
push:
branches: [main]
paths:
- ".github/workflows/geocoding-service-package.yml"
- "geocoding/location-service/**"
# Build whenever a new tag is created.
tags:
- "*"
workflow_dispatch:
pull_request:
paths:
- ".github/workflows/geocoding-service-package.yml"
jobs:
build-and-push:
runs-on: ubuntu-20.04
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v3
-
name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/${{github.repository}}/locationservice
VERSION=edge
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
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [ "${{ github.event_name }}" = "push" ]; then
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
fi
echo ::set-output name=tags::${TAGS}
- uses: docker/login-action@v2
with:
username: ${{ github.actor }}
# https://github.com/globaldothealth/list/settings/secrets
# https://docs.github.com/en/packages/getting-started-with-github-container-registry/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- uses: docker/build-push-action@v3
with:
file: geocoding/location-service/Dockerfile
push: true
tags: ${{ steps.prep.outputs.tags }}