This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
78 lines (61 loc) · 2.34 KB
/
azure-pipelines.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
trigger:
- master
- refs/tags/*
jobs:
- job: BuildDockerImage
pool:
vmImage: 'Ubuntu-16.04'
strategy:
matrix:
ubuntu-1604:
ubuntu.version.dot: '16.04'
ubuntu.version.name: '1604'
ubuntu-1804:
ubuntu.version.dot: '18.04'
ubuntu.version.name: '1804'
# ubuntu-1904:
# ubuntu.version.dot: '19.04'
# ubuntu.version.name: '1904'
variables:
- group: hwangsaeul-dockerhub
steps:
- bash: |
docker build \
-f docker/ubuntu/Dockerfile.$(ubuntu.version.dot) \
-t hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name) docker/ubuntu
displayName: Build docker image
- bash: |
TAG=`git tag --contains`
PARSED_TAG=`echo "$TAG" | egrep -o "^(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))+(\-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$"`
if [ x"$PARSED_TAG" != "x" ]; then
docker login -u $(dockerhub.id) -p $(dockerhub.passwd) $(dockerhub.host)
docker tag \
hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name) \
$(dockerhub.host)/hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name):$PARSED_TAG
docker tag \
hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name) \
$(dockerhub.host)/hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name):latest
docker push \
$(dockerhub.host)/hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name):$PARSED_TAG
docker push \
$(dockerhub.host)/hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name):latest
fi
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
displayName: Push images to DockerHub
- bash: |
docker login -u $(dockerhub.id) -p $(dockerhub.passwd) $(dockerhub.host)
SHORT_GIT_HASH=`git rev-parse --short HEAD`
docker save \
hwangsaeul/h8l-ci-ubuntu-$(ubuntu.version.name) | gzip > h8l-ci-ubuntu-$(ubuntu.version.name)-$SHORT_GIT_HASH.tgz
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
displayName: Archiving docker image
- task: CopyFiles@2
condition: not(canceled())
inputs:
contents: '*.tgz'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
inputs:
artifactName: $(System.JobName)
# publishing artifacts from PRs from a fork is currently blocked
condition: not(canceled())