-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathazure-pipelines.yaml
90 lines (76 loc) · 2.7 KB
/
azure-pipelines.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
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
trigger:
- master
pr: none
resources:
repositories:
- repository: helmRepo
type: github
endpoint: John D Watson
name: johnwatson484/helm-charts
pool:
vmImage: 'ubuntu-latest'
variables:
repo: helm-library
helmRepo: helm-charts
helmRepositoryUrl: git@github.com:johnwatson484/helm-charts.git
version:
releaseExists: false
steps:
- checkout: self
displayName: Clone repository
- task: HelmInstaller@1
displayName: Install Helm
inputs:
helmVersionToInstall: 'latest'
- bash: |
helmVersion=$(helm show chart $(Agent.BuildDirectory)/s/$(repo)/$(repo) | awk '/version:/ {print $2}')
echo "##vso[task.setvariable variable=version;]$helmVersion"
displayName: Set version
- checkout: helmRepo
displayName: Clone Helm repository
- script: |
helm package $(Agent.BuildDirectory)/s/$(repo)/$(repo) --destination $(Agent.BuildDirectory)/s/$(helmRepo)
displayName: Package Helm
- task: DownloadSecureFile@1
name: sshKey
displayName: Download SSH key
inputs:
secureFile: 'GitHub-Helm-Deploy-Key'
- script: |
mkdir ~/.ssh && mv $(sshKey.secureFilePath) ~/.ssh/id_rsa
chmod 700 ~/.ssh && chmod 600 ~/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
displayName: Install SSH key
- script: |
cd $(Agent.BuildDirectory)/s/$(helmRepo)
git config --global user.email "azuredevops@microsoft.com"
git config --global user.name "Azure DevOps"
git remote set-url --push origin $(helmRepositoryUrl)
git pull origin master
helm repo index . --merge ./index.yaml
git add .
git commit -m "$(repo) updated by Azure DevOps"
git push origin HEAD:master
displayName: Update Helm repo
- task: PowerShell@2
displayName: Check GitHub release
inputs:
targetType: 'inline'
script: |
$releaseExists = (Invoke-RestMethod -SkipHttpErrorCheck -Uri 'https://api.github.com/repos/johnwatson484/$(repo)/releases/tags/$(version)').tag_name -eq '$(version)'
Write-Host "##vso[task.setvariable variable=releaseExists;]$releaseExists"
- task: GitHubRelease@1
displayName: GitHub release
inputs:
gitHubConnection: 'John D Watson PAT'
repositoryName: '$(Build.Repository.Name)'
action: 'create'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: '$(version)'
title: '$(version)'
releaseNotesSource: 'inline'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
continueOnError: true
condition: and(succeeded(), eq(variables.releaseExists, false))