dd-trace-dotnet-nightly #298
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |