Add workflow docker-publish.yml

This commit is contained in:
Robert
2021-04-23 14:15:24 -07:00
committed by GitHub
parent b1674b0066
commit 1d41bb8e78
+81
View File
@@ -0,0 +1,81 @@
name: Convoar Docker image
on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
env:
IMAGE_NAME: convoar
IMAGE_OWNER: herbal3d
jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: checkout
uses: actions/checkout@v2
- name: Extract version information
run: |
echo "CVERSION=$(cat VERSION)" >> $GITHUB_ENV
echo "CVERSION=$CVERSION"
echo "GITHUB_ACTOR=$GITHUB_ACTOR"
echo "GITHUB_REF=$GITHUB_REF"
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
#- name: Setup QEMU
# uses: docker/setup-qemu-action@v1
- name: Login to Github Container registry
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
# platforms: linux/amd64
# platforms: linux/amd64,linux/arm64
push: true
tags: |
$IMAGE_OWNER/$IMAGE_NAME: latest
$IMAGE_OWNER/$IMAGE_NAME: $CVERSION
ghcr.io/$IMAGE_OWNER/$IMAGE_NAME: latest
ghcr.io/$IMAGE_OWNER/$IMAGE_NAME: $CVERSION
# run: |
# cd docker
# docker build . --file Dockerfile --build-args VERSION=$VERSION --tag $IMAGE_NAME
#- name: Log into registry
# run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
#- name: Push image
# run: |
# IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# 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
# echo VERSION=$VERSION
#docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
#docker push $IMAGE_ID:$VERSION