Skip to content

Commit

Permalink
Trigger workflow on release
Browse files Browse the repository at this point in the history
  • Loading branch information
seallard committed Oct 23, 2023
1 parent d7c87a6 commit 21c031b
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions .github/workflows/build_cli_image_on_push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Build and publish cli image on push
name: Build and publish cli image on push or new release event

on: [push]
on:
push:
release:
types:
- created

jobs:
docker-image-push:
Expand All @@ -12,19 +16,42 @@ jobs:
- name: Extract branch name and remove illegal chars
id: get_branch_name
shell: bash
run: echo "branch=$(tr "/" "-" <<<${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
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: "clinicalgenomics/cg-cli:${{ env.branch }}"
tags: ${{ steps.set_tag.outputs.tags }}

0 comments on commit 21c031b

Please sign in to comment.