Add GitHub Action workflow to build and publish to the GitHub Container registry

pull/186/head
Vincent Emonet 3 years ago committed by Thomas Tanon
parent 5dd2b2df09
commit 682b75b957
  1. 51
      .github/workflows/docker.yml

@ -0,0 +1,51 @@
name: Publish Oxigraph server image
on:
workflow_dispatch:
push:
# Publish `master` branch as Docker `latest` image.
branches:
- master
paths:
- 'Dockerfile'
- 'lib/**'
- 'server/**'
- '.github/workflows/docker.yml'
# Publish `v0.1.2` release as image tag `0.1.2`.
release:
types: [published]
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Generate image ID and version
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/oxigraph
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build docker image
run: |
docker build -t $IMAGE_ID:$VERSION .
- name: Push docker image
run: |
docker push $IMAGE_ID:$VERSION
Loading…
Cancel
Save