-
Notifications
You must be signed in to change notification settings - Fork 3
58 lines (51 loc) · 1.75 KB
/
build_publish_cli_image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Build and Publish CLI Image
on:
push:
release:
types:
- created
jobs:
docker-image-push:
runs-on: ubuntu-latest
steps:
- name: Check out git repository
uses: actions/[email protected]
- name: Prepare Branch Name
id: prepare_branch_name
shell: bash
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
# Replace slashes with hyphens in the branch name
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 Release Version
id: get_release_version
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
VERSION=${{ github.event.release.tag_name }}
echo "::set-output name=version::$VERSION"
fi
- name: Prepare Docker Tags
id: prepare_docker_tags
shell: bash
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "::set-output name=tags::clinicalgenomics/cg-cli:${{ steps.get_release_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 Docker Image
id: docker_cli_build
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile-cli
push: true
tags: ${{ steps.prepare_docker_tags.outputs.tags }}