Skip to content

Commit d57c104

Browse files
committed
ci/cd test
1 parent 91093f1 commit d57c104

File tree

4 files changed

+222
-0
lines changed

4 files changed

+222
-0
lines changed

.github/workflows/apigenerator.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build and deploy .NET Core application to windows webapp apigenerator with API Management Service ApiGeneratorSampleApIapi
2+
on:
3+
push:
4+
branches:
5+
- vnext
6+
env:
7+
AZURE_WEBAPP_NAME: apigenerator
8+
DOTNET_CORE_VERSION: 6.0.x
9+
WORKING_DIRECTORY: sample\ApiGeneratorSampleApp
10+
CONFIGURATION: Release
11+
AZURE_WEBAPP_PACKAGE_PATH: sample\ApiGeneratorSampleApp/publish
12+
AZURE_APIM_RESOURCE_PATH: /generated
13+
AZURE_APIM_RESOURCEGROUP: apigenerator_group
14+
AZURE_APIM_SERVICENAME: ApiGeneratorSampleApIapi
15+
AZURE_APIM_API_ID: ApiGeneratorSampleApI
16+
AZURE_APIM_APPSERVICEURL: https://apigenerator.azurewebsites.net:80/
17+
SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION: 5.6.3
18+
SWASHBUCKLE_DOTNET_CORE_VERSION: 3.1.x
19+
API_IMPORT_SPECIFICATION_PATH: sample\ApiGeneratorSampleApp/publish/swagger.json
20+
API_IMPORT_DLL: sample\ApiGeneratorSampleApp/publish/ApiGeneratorSampleApI.dll
21+
API_IMPORT_VERSION: v1
22+
jobs:
23+
build:
24+
runs-on: windows-latest
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Setup .NET Core
28+
uses: actions/setup-dotnet@v1
29+
with:
30+
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
31+
- name: Setup SwashBuckle .NET Core
32+
uses: actions/setup-dotnet@v1
33+
with:
34+
dotnet-version: ${{ env.SWASHBUCKLE_DOTNET_CORE_VERSION }}
35+
- name: Restore
36+
run: dotnet restore ${{ env.WORKING_DIRECTORY }}
37+
- name: Build
38+
run: dotnet build ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-restore
39+
- name: Test
40+
run: dotnet test ${{ env.WORKING_DIRECTORY }} --no-build
41+
- name: Publish
42+
run: dotnet publish ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-build --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
43+
- name: Install Swashbuckle CLI .NET Global Tool
44+
run: dotnet tool install --global Swashbuckle.AspNetCore.Cli --version ${{ env.SWASHBUCLE_ASPNET_CORE_CLI_PACKAGE_VERSION }}
45+
working-directory: ${{ env.WORKING_DIRECTORY }}
46+
- name: Generate Open API Specification Document
47+
run: swagger tofile --output "${{ env.API_IMPORT_SPECIFICATION_PATH }}" "${{ env.API_IMPORT_DLL }}" "${{ env.API_IMPORT_VERSION }}"
48+
- name: Publish Artifacts
49+
uses: actions/[email protected]
50+
with:
51+
name: webapp
52+
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
53+
deploy:
54+
runs-on: windows-latest
55+
needs: build
56+
steps:
57+
- name: Download artifact from build job
58+
uses: actions/download-artifact@v2
59+
with:
60+
name: webapp
61+
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
62+
- name: Deploy to Azure WebApp
63+
uses: azure/webapps-deploy@v2
64+
with:
65+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
66+
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
67+
publish-profile: ${{ secrets.apigenerator_c1d7 }}
68+
- name: Azure Login
69+
uses: azure/login@v1
70+
with:
71+
creds: ${{ secrets.ApiGeneratorSampleApIapi_spn }}
72+
- name: Import API into Azure API Management
73+
run: az apim api import --path "${{ env.AZURE_APIM_RESOURCE_PATH }}" --resource-group "${{ env.AZURE_APIM_RESOURCEGROUP }}" --service-name "${{ env.AZURE_APIM_SERVICENAME }}" --api-id "${{ env.AZURE_APIM_API_ID }}" --service-url "${{ env.AZURE_APIM_APPSERVICEURL }}" --specification-path "${{ env.API_IMPORT_SPECIFICATION_PATH }}" --specification-format OpenApi --subscription-required false
74+
- name: logout
75+
run: >
76+
az logout
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"resourceGroupName": {
6+
"type": "string",
7+
"defaultValue": "apigenerator_group",
8+
"metadata": {
9+
"_parameterType": "resourceGroup",
10+
"description": "Der Name der Ressourcengruppe für die Ressource. Es wird empfohlen, Ressourcen für eine bessere Nachverfolgung in derselben Ressourcengruppe zu platzieren."
11+
}
12+
},
13+
"resourceGroupLocation": {
14+
"type": "string",
15+
"defaultValue": "westeurope",
16+
"metadata": {
17+
"_parameterType": "location",
18+
"description": "Der Standort der Ressourcengruppe. Ressourcengruppen können andere Standorte als Ressourcen aufweisen."
19+
}
20+
},
21+
"resourceLocation": {
22+
"type": "string",
23+
"defaultValue": "[parameters('resourceGroupLocation')]",
24+
"metadata": {
25+
"_parameterType": "location",
26+
"description": "Der Standort der Ressource. Verwenden Sie standardmäßig den Standort der Ressourcengruppe, sofern der Ressourcenanbieter dort unterstützt wird."
27+
}
28+
}
29+
},
30+
"resources": [
31+
{
32+
"type": "Microsoft.Resources/resourceGroups",
33+
"name": "[parameters('resourceGroupName')]",
34+
"location": "[parameters('resourceGroupLocation')]",
35+
"apiVersion": "2019-10-01"
36+
},
37+
{
38+
"type": "Microsoft.Resources/deployments",
39+
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('ApiGeneratorSampleApI', subscription().subscriptionId)))]",
40+
"resourceGroup": "[parameters('resourceGroupName')]",
41+
"apiVersion": "2019-10-01",
42+
"dependsOn": [
43+
"[parameters('resourceGroupName')]"
44+
],
45+
"properties": {
46+
"mode": "Incremental",
47+
"template": {
48+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
49+
"contentVersion": "1.0.0.0",
50+
"resources": [
51+
{
52+
"name": "ApiGeneratorSampleApIapi",
53+
"type": "Microsoft.ApiManagement/service",
54+
"location": "[parameters('resourceLocation')]",
55+
"properties": {
56+
"publisherEmail": "[email protected]",
57+
"publisherName": "Tim Cadenbach",
58+
"notificationSenderEmail": "[email protected]",
59+
"hostnameConfigurations": [
60+
{
61+
"type": "Proxy",
62+
"hostName": "apigeneratorsampleapiapi.azure-api.net",
63+
"encodedCertificate": null,
64+
"keyVaultId": null,
65+
"certificatePassword": null,
66+
"negotiateClientCertificate": false,
67+
"certificate": null,
68+
"defaultSslBinding": true
69+
}
70+
],
71+
"publicIPAddresses": null,
72+
"privateIPAddresses": null,
73+
"additionalLocations": null,
74+
"virtualNetworkConfiguration": null,
75+
"customProperties": {
76+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10": "False",
77+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11": "False",
78+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10": "False",
79+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11": "False",
80+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Ssl30": "False",
81+
"Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2": "False"
82+
},
83+
"virtualNetworkType": "None",
84+
"certificates": null,
85+
"apiVersionConstraint": {
86+
"minApiVersion": null
87+
}
88+
},
89+
"sku": {
90+
"name": "Consumption",
91+
"capacity": 0
92+
},
93+
"apiVersion": "2019-12-01"
94+
},
95+
{
96+
"type": "Microsoft.ApiManagement/service/apis",
97+
"name": "ApiGeneratorSampleApIapi/ApiGeneratorSampleApI",
98+
"properties": {
99+
"displayName": "ApiGeneratorSampleApI",
100+
"apiRevision": "1",
101+
"description": null,
102+
"subscriptionRequired": true,
103+
"serviceUrl": null,
104+
"path": "generated",
105+
"protocols": [
106+
"https"
107+
],
108+
"authenticationSettings": {
109+
"oAuth2": null,
110+
"openid": null
111+
},
112+
"subscriptionKeyParameterNames": {
113+
"header": "Ocp-Apim-Subscription-Key",
114+
"query": "subscription-key"
115+
},
116+
"isCurrent": true
117+
},
118+
"apiVersion": "2019-12-01",
119+
"dependsOn": [
120+
"ApiGeneratorSampleApIapi"
121+
]
122+
}
123+
]
124+
}
125+
}
126+
}
127+
],
128+
"metadata": {
129+
"_dependencyType": "apis.azure"
130+
}
131+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"dependencies": {
3+
"apis1": {
4+
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.ApiManagement/service/ApiGeneratorSampleApIapi/apis/ApiGeneratorSampleApI",
5+
"type": "apis.azure"
6+
}
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"dependencies": {
3+
"apis1": {
4+
"type": "apis"
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)