forked from clinical-genomics-uppsala/Twist_DNA
-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.57 KB
/
dockerbuild_develop_master.yaml
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
# This is a basic workflow to help you get started with Actions
name: develop/master
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the dev branch
push:
branches:
- master
- develop
paths:
- 'dockerfiles/**/VERSION'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
docker_build_push:
name: docker build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Log into registry
run: echo "${{ secrets.HUB_PASSWORD }}" | docker login ${{ secrets.DOCKER_REGISTRY_URL }} -u ${{ secrets.DOCKERHUB_USER }} --password-stdin
- name: Build and push the images
run: |
for versionFilePath in $(git diff-tree --no-commit-id -r ${{ github.event.before }} ${{ github.sha }} | awk '{if($5 != "D") print($6)}' | grep "VERSION");
do
folder=${versionFilePath%"/VERSION"}
IMAGE_NAME=${folder##*/}
tmpName="image-$RANDOM"
docker build $folder --file $folder/Dockerfile --tag $tmpName
IMAGE_ID=${{ secrets.DOCKER_REGISTRY_URL }}/${{ secrets.REPOSITORY }}/$IMAGE_NAME
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//_/g')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $tmpName $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
done;