-
-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathazure-pipelines.yml
117 lines (99 loc) · 2.89 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Copyright (c) .NET Foundation and Contributors
# See LICENSE file in the project root for full license information.
trigger:
branches:
include:
- main
paths:
exclude:
- .gitignore
- CODE_OF_CONDUCT.md
- LICENSE.md
- README.md
- README.zh-cn.md
- NuGet.Config
- .github/*
# PR always trigger build
pr:
autoCancel: true
# add nf-tools repo to resources (for Azure Pipelines templates)
resources:
repositories:
- repository: templates
type: github
name: nanoframework/nf-tools
endpoint: nanoframework
pool:
vmImage: 'windows-latest'
variables:
DOTNET_NOLOGO: true
steps:
# need this here in order to persist GitHub credentials
# only need the latest commit
- checkout: self
- script: |
git config --global user.email '[email protected]'
git config --global user.name 'nfbot'
git config --global core.autocrlf true
displayName: Setup git identity
- task: Cache@2
displayName: Cache NuGet packages
condition: succeeded()
continueOnError: true
inputs:
key: 'nuget | **/packages.config'
path: $(UserProfile)/.nuget/packages
- task: InstallNanoMSBuildComponents@1
displayName: Install nanoFramework MSBuild components
env:
GITHUB_TOKEN: $(GitHubToken)
# only build solutions that were changed
- task: PowerShell@2
displayName: Build solutions
inputs:
targetType: 'filePath'
filePath: '$(System.DefaultWorkingDirectory)\.pipeline-assets\build-solutions.ps1'
failOnStderr: true
env:
MY_GITHUBTOKEN: $(GitHubToken)
# Adjust the readmes
- task: DotNetCoreCLI@2
displayName: Adjust READMEs
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
inputs:
command: custom
custom: run
projects: '**/device-listing.csproj'
workingDirectory: 'Samples'
- task: PowerShell@2
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], '')
)
displayName: Push READMEs to GitHub
continueOnError: true
inputs:
targetType: 'inline'
workingDirectory: 'Samples'
script: |
git add README.md
git add README.zh-cn.md
git commit -m "Update READMEs" -m"***NO_CI***"
Write-Host "Rebasing..."
git rebase origin/main
Write-Host "Pushing READMEs to $(Build.SourceBranchName)"
# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$(GitHubToken)")))"
git -c http.extraheader="AUTHORIZATION: $auth" push origin "HEAD:$(Build.SourceBranchName)"
# report error
- template: azure-pipelines-templates/discord-webhook-task.yml@templates
parameters:
status: 'failure'
webhookUrl: '$(DiscordWebhook)'
message: ''