name: Publish Docker 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 with: submodules: 'recursive' - 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