Skip to content

Trigger workflow on release #15

Trigger workflow on release

Trigger workflow on release #15

name: Build and publish cli image on push or new release event
on:
push:
release:
types:
- created
jobs:
docker-image-push:
runs-on: ubuntu-latest
steps:
- name: Check out git repository
uses: actions/checkout@v3
- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "branch=$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
fi
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get the release version
id: get_version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION=${{ github.event.release.tag_name }}
echo "::set-output name=version::$VERSION"
fi
- name: Set tag names
id: set_tag
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "::set-output name=tags::clinicalgenomics/cg-cli:${{ steps.get_version.outputs.version }},clinicalgenomics/cg-cli:latest"
else
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr "/" "-")
echo "::set-output name=tags::clinicalgenomics/cg-cli:$BRANCH_NAME"
fi
- name: Build and push
id: docker_cli_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile.cli
push: true
tags: ${{ steps.set_tag.outputs.tags }}