-
Notifications
You must be signed in to change notification settings - Fork 5.1k
102 lines (89 loc) · 3.99 KB
/
generate-swagger-apiview-tokens.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
name: Generate APIView Artifact
on:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
AzureSdkForNetDevOpsFeed:
description: 'Azure SDK for .NET DevOps Feed'
default: 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json'
SwaggerApiParserVersion:
description: 'Swagger API Parser Version'
default: '1.3.0-dev.20241029.2'
APIViewArtifactsDirectoryName:
description: 'APIView Artifacts Directory Name'
default: 'SwaggerAPIViewArtifacts'
APIViewArtifactsName:
description: 'APIView Artifacts Name'
default: 'swaggerAPIViewArtifacts'
APIViewAPIUri:
description: 'URI for APIView Creation Endpoint'
default: 'https://apiviewstagingtest.com/PullRequest/DetectAPIChanges'
PullRequestRef:
description: 'Pull Request ref'
default: 'refs/pull/5/merge'
PullRequestNumber:
description: 'Pull Request Number'
default: '5'
env:
AzureSdkForNetDevOpsFeed: ${{ github.event.inputs.AzureSdkForNetDevOpsFeed || 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json' }}
SwaggerApiParserVersion: ${{ github.event.inputs.SwaggerApiParserVersion || '1.3.0-dev.20241029.2' }}
APIViewArtifactsDirectoryName: ${{ github.event.inputs.APIViewArtifactsDirectoryName || 'SwaggerAPIViewArtifacts' }}
APIViewArtifactsName: ${{ github.event.inputs.APIViewArtifactsName || 'swaggerAPIViewArtifacts' }}
APIViewAPIUri: ${{ github.event.inputs.APIViewAPIUri || 'https://apiview.dev/PullRequest/DetectAPIChanges' }}
PullRequestRef: ${{ github.event.pull_request.head.ref || github.event.inputs.PullRequestRef }}
PullRequestNumber: ${{ github.event.pull_request.number || github.event.inputs.PullRequestNumber }}
jobs:
generate-apiview-artifact:
runs-on: ubuntu-latest
outputs:
APIViewArtifactsDirectoryName: ${{ steps.set-outputs.outputs.APIViewArtifactsDirectoryName }}
APIViewArtifactsName: ${{ steps.set-outputs.outputs.APIViewArtifactsName }}
APIViewAPIUri: ${{ steps.set-outputs.outputs.APIViewAPIUri }}
PullRequestRef: ${{ steps.set-outputs.outputs.PullRequestRef }}
PullRequestNumber: ${{ steps.set-outputs.outputs.PullRequestNumber }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ env.PullRequestRef }}
fetch-depth: 0
- name: Install .NET SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.x'
- name: Install APIView Swagger Parser
run: |
dotnet tool install Azure.Sdk.Tools.SwaggerApiParser \
--version ${{ env.SwaggerApiParserVersion }} \
--add-source ${{ env.AzureSdkForNetDevOpsFeed }} \
--global
- name: Generate Swagger APIView Tokens
shell: pwsh
run: |
eng/scripts/Create-Swagger-APIView-Artifacts.ps1 `
-TempDirectory ${{ github.workspace }}/temp `
-ArtiFactsStagingDirectory ${{ github.workspace }}/artifacts `
-APIViewArtifactsDirectoryName ${{ env.APIViewArtifactsDirectoryName }}
env:
DOTNET_ROOT: /home/runner/.dotnet
- name: Publish Swagger APIView Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.APIViewArtifactsName }}
path: ${{ github.workspace }}/artifacts/${{ env.APIViewArtifactsDirectoryName }}
- name: Output Env Variables to JSON
run: |
echo '{
"APIViewArtifactsDirectoryName": "${{ env.APIViewArtifactsDirectoryName }}",
"APIViewArtifactsName": "${{ env.APIViewArtifactsName }}",
"APIViewAPIUri": "${{ env.APIViewAPIUri }}",
"PullRequestRef": "${{ env.PullRequestRef }}",
"PullRequestNumber": "${{ env.PullRequestNumber }}"
}' > output-parameters.json
- name: Upload JSON as Artifact
uses: actions/upload-artifact@v4
with:
name: workflow-params
path: output-parameters.json