-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-DotCast.App.yml
99 lines (83 loc) · 2.77 KB
/
build-DotCast.App.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
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
name: default
variables:
buildConfiguration: 'Release'
steps:
- task: Bash@3
displayName: 'Replace submodule URLs with PAT and pull submodules'
inputs:
targetType: 'inline'
script: |
echo "Adding PAT to submodule URLs"
# Ensure the PAT environment variable is available
if [ -z "$PAT" ]; then
echo "Error: PAT environment variable is not set."
exit 1
fi
# Get the submodule URLs from .gitmodules
submodules=$(git config -f .gitmodules --get-regexp '^submodule\..*\.url$')
# Loop through each line of submodule data
echo "$submodules" | while IFS= read -r line; do
# Skip empty lines
if [ -z "$line" ]; then
continue
fi
# Split the line into key and value
key=$(echo "$line" | awk '{print $1}')
url=$(echo "$line" | awk '{print $2}')
echo "Processing $key"
# Insert the PAT into the URL
# Replace existing authentication info (if any) with the PAT
new_url=$(echo "$url" | sed -E "s|https://[^@]*@|https://$PAT@|")
# If there was no existing auth info, insert the PAT after https://
if [ "$new_url" = "$url" ]; then
new_url=$(echo "$url" | sed -E "s|https://|https://$PAT@|")
fi
# Update the .gitmodules file
git config -f .gitmodules "$key" "$new_url"
done
# Synchronize the submodule URLs
git submodule sync
# Pull the submodule code
git submodule update --init --recursive
# Reset the .gitmodules file to avoid committing the PAT
git checkout .gitmodules
env:
PAT: $(PAT)
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '**/DotCast.sln'
displayName: 'Restore Nuget Packages'
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/DotCast.App.csproj'
arguments: '/p:DefineConstants=LINUX -r linux-x64 --configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: '**/DotCast.App.csproj'
arguments: '/p:DefineConstants=LINUX -r linux-x64 --configuration $(buildConfiguration) --output $(Build.ArtifactStagingDirectory)'
modifyOutputPath: false
zipAfterPublish: false
displayName: 'Publish'
- task: Docker@2
inputs:
containerRegistry: 'Private Registry 2'
command: 'login'
- task: Docker@2
inputs:
containerRegistry: 'Private Registry 2'
repository: DotCast
tags: $(Build.BuildId)
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
buildContext: $(Build.ArtifactStagingDirectory)