forked from eclipse-iofog/iofog.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
97 lines (85 loc) · 3.26 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
trigger:
tags:
include:
- v*
branches:
include:
- develop
paths:
exclude:
- README.md
variables:
group: 'pipelines'
stagingCluster: 'iofogctl-ci'
stagingClusterRegion: 'us-central1-a'
repository: 'focal-freedom-236620/iofogorg'
buildTag: $(Build.BuildId)
branchTag: $(Build.SourceBranchName)
jobs:
- job: "ioFog"
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- script: |
npm run build
displayName: 'npm build'
- bash: |
if [ "${BRANCHTAG}" = "master" ] || [ "${SYSTEM_PULLREQUEST_TARGETBRANCH}" = "master" ]; then
EDIT_LINK_TAG="master"
else
EDIT_LINK_TAG="develop"
fi
echo "Replacing branch name in github links to: ${EDIT_LINK_TAG}"
find content/docs/2 -name ‘*.md’ -exec sed -i "" “s/\(https:\/\/github.com\/eclipse-iofog\/iofog.org\/edit\/\)develop\//\1${EDIT_LINK_TAG}\//” {} \;
- task: Docker@2
displayName: 'build docker'
inputs:
containerRegistry: 'Edgeworx GCP'
repository: $(repository)
command: 'build'
Dockerfile: "Dockerfile"
tags: |
$(buildTag)
condition: ne(variables['Build.Reason'], 'PullRequest')
- task: Docker@2
displayName: 'push docker'
inputs:
containerRegistry: 'Edgeworx GCP'
repository: $(repository)
command: 'push'
Dockerfile: "Dockerfile"
tags: |
$(buildTag)
condition: ne(variables['Build.Reason'], 'PullRequest')
- task: DownloadSecureFile@1
displayName: 'Download secure file'
inputs:
secureFile: 'azure-gcp.json'
condition: ne(variables['Build.Reason'], 'PullRequest')
- bash: |
CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install google-cloud-sdk
gcloud --quiet auth activate-service-account --key-file=$(Agent.TempDirectory)/azure-gcp.json
gcloud --quiet config set project focal-freedom-236620
gcloud --quiet container clusters get-credentials $(stagingCluster) --region $(stagingClusterRegion)
gcloud --quiet auth configure-docker
displayName: 'set up gcloud'
condition: ne(variables['Build.Reason'], 'PullRequest')
- bash: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
displayName: 'set up kubectl'
condition: ne(variables['Build.Reason'], 'PullRequest')
- bash: |
sed "s/{{BUILD_NUMBER}}/$(buildTag)/g" "deploy/staging.yaml" | ./kubectl apply -f -
displayName: 'update deployment'
condition: ne(variables['Build.Reason'], 'PullRequest')