-
Notifications
You must be signed in to change notification settings - Fork 11
153 lines (125 loc) · 8.29 KB
/
update_aas_extension.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Update extension on AAS, triggered by dd-trace-dotnet nightly build
on:
workflow_dispatch:
inputs:
sha:
description: 'Hash commit of dd-trace-dotnet build'
required: true
repository_dispatch:
types: [dd-trace-dotnet-nightly, dd-trace-code-freeze]
jobs:
update_extension:
permissions:
contents: read
actions: read # read secrets
packages: write # pushing to ghcr.io
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
steps:
- name: "Set Variables"
id: "set_variables"
run: |
if [[ ! -z "${{ github.event.inputs.sha }}" ]]; then
echo "::set-output name=sha::${{ github.event.inputs.sha }}"
elif [[ ! -z "${{ github.event.client_payload.sha }}" ]]; then
echo "::set-output name=sha::${{ github.event.client_payload.sha }}"
else
echo "Error. Hash commit wasn't provided in input."
exit 1
fi
- name: Checkout
uses: actions/checkout@v2
- name: "Modify build-packages-dev"
id: "versions"
run: |
versionRegex="[0-9]*.[0-9]*.[0-9]*"
splitVersionRegex="([0-9]+).([0-9]+).([0-9]+)"
CURRENT_DEV_VERSION="$(grep -o -e DEVELOPMENT_VERSION\=\"$versionRegex dotnet/build-packages-dev.sh | sed 's/DEVELOPMENT_VERSION="//')"
echo Current dev version is: $CURRENT_DEV_VERSION
major=0
minor=0
# Use the current unit time (in seconds) as the build ID, to ensure monotonically increasing numbers
# Previously we were using github.run_id but this value is too large. This should work until
# date +%s returns > 2147483647, i.e. we're ok until Tuesday, 19 January 2038 03:14:08
build=$(date +%s)
if [[ $CURRENT_DEV_VERSION =~ $splitVersionRegex ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
fi
DEV_VERSION=$major.$minor.$(echo $build | bc)
echo New dev version is $DEV_VERSION
echo "::set-output name=dev_version::$DEV_VERSION"
sed -i -e "s/DEVELOPMENT_VERSION=\"$CURRENT_DEV_VERSION/DEVELOPMENT_VERSION=\"$DEV_VERSION/g" dotnet/build-packages-dev.sh
echo Replaced dev version in file.
sha=${{ steps.set_variables.outputs.sha }}
echo Setting install sha to $sha
sed -i -e "s/INSTALL_SHA/$sha/g" dotnet/build-packages-dev.sh
echo Replaced install sha in file.
- name: Login to Docker
run: docker login -u publisher -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Build and push Junkyard WebApp Docker image
id: build-image-amd64
uses: docker/build-push-action@v3
with:
push: true
tags: 'ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }}'
context: ./dotnet/docker
file: ./dotnet/docker/dotnet_release_app.dockerfile
build-args: |
APM_COMMIT_SHA=${{ steps.set_variables.outputs.sha }}
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.100'
- name: "Build nuget package"
run: |
bash dotnet/build-packages-dev.sh
- name: "Upload dev nuget"
run: |
dotnet nuget add source https://pkgs.dev.azure.com/datadoghq/dd-trace-dotnet/_packaging/Public_Feed/nuget/v3/index.json --name Public_Feed --username any_string --password ${{ secrets.AZDO_PAT }} --store-password-in-clear-text
dev_version="${{steps.versions.outputs.dev_version}}-prerelease"
dotnet nuget push package/DevelopmentVerification.DdDotNet.Apm.$dev_version.nupkg --source Public_Feed --api-key any_string
- name: Azure CLI script
uses: azure/CLI@v1
with:
inlineScript: |
resourceGroupName="apm-aas-junkyard"
aasName="dd-dotnet-latest-build"
aasStatsName="dd-dotnet-latest-build-stats"
aasProfilerOnlyName="dd-dotnet-latest-build-profiler-only"
aasProfilerBackendName="dd-dotnet-profiler-backend-test-latest-build"
aasSecuritySample="dd-dotnet-security-aspnetcore"
echo "Login"
az login --service-principal -u ${{ secrets.AZURE_APP_ID }} -p ${{ secrets.AZURE_PASSWORD }} --tenant ${{ secrets.AZURE_TENANT }}
echo "Update Site Extensions"
az resource create --resource-group $resourceGroupName --resource-type "Microsoft.Web/sites/siteextensions" --name "$aasName/siteextensions/DevelopmentVerification.DdDotNet.Apm" -p "{}"
az resource create --resource-group $resourceGroupName --resource-type "Microsoft.Web/sites/siteextensions" --name "$aasStatsName/siteextensions/DevelopmentVerification.DdDotNet.Apm" -p "{}"
az resource create --resource-group $resourceGroupName --resource-type "Microsoft.Web/sites/siteextensions" --name "$aasProfilerOnlyName/siteextensions/DevelopmentVerification.DdDotNet.Apm" -p "{}"
az resource create --resource-group $resourceGroupName --resource-type "Microsoft.Web/sites/siteextensions" --name "$aasProfilerBackendName/siteextensions/DevelopmentVerification.DdDotNet.Apm" -p "{}"
az resource create --resource-group $resourceGroupName --resource-type "Microsoft.Web/sites/siteextensions" --name "$aasSecuritySample/siteextensions/DevelopmentVerification.DdDotNet.Apm" -p "{}"
aasLinuxBaseLine="dd-dotnet-linux-baseline"
aasLinuxDotnetLatestName="dd-dotnet-linux-latest-build"
aasLinuxStatsName="dd-dotnet-linux-latest-build-stats"
aasLinuxProfilerDefaultName="dd-dotnet-linux-latest-build-profiler-default"
aasLinuxProfilerAllName="dd-dotnet-linux-latest-build-profiler-all"
echo "Update Linux Image Version"
# We need to update the baseline too, in case the application code changed.
az webapp config container set --name $aasLinuxBaseLine --resource-group $resourceGroupName --docker-custom-image-name ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }} --docker-registry-server-url https://docker.io
az webapp config container set --name $aasLinuxDotnetLatestName --resource-group $resourceGroupName --docker-custom-image-name ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }} --docker-registry-server-url https://docker.io
az webapp config container set --name $aasLinuxStatsName --resource-group $resourceGroupName --docker-custom-image-name ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }} --docker-registry-server-url https://docker.io
az webapp config container set --name $aasLinuxProfilerDefaultName --resource-group $resourceGroupName --docker-custom-image-name ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }} --docker-registry-server-url https://docker.io
az webapp config container set --name $aasLinuxProfilerAllName --resource-group $resourceGroupName --docker-custom-image-name ghcr.io/datadog/dd-trace-dotnet/junkyard-release-app:${{ steps.set_variables.outputs.sha }} --docker-registry-server-url https://docker.io
echo "Waiting 10 seconds for extension to be actually installed"
sleep 10
echo "Restart Application"
az webapp restart --resource-group $resourceGroupName --name $aasName
az webapp restart --resource-group $resourceGroupName --name $aasStatsName
az webapp restart --resource-group $resourceGroupName --name $aasProfilerOnlyName
az webapp restart --resource-group $resourceGroupName --name $aasProfilerBackendName
az webapp restart --resource-group $resourceGroupName --name $aasSecuritySample
# Linux apps
az webapp restart --resource-group $resourceGroupName --name $aasLinuxBaseLine
az webapp restart --resource-group $resourceGroupName --name $aasLinuxDotnetLatestName
az webapp restart --resource-group $resourceGroupName --name $aasLinuxStatsName
az webapp restart --resource-group $resourceGroupName --name $aasLinuxProfilerDefaultName
az webapp restart --resource-group $resourceGroupName --name $aasLinuxProfilerAllName