forked from Azure/apiops
-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (121 loc) · 5.92 KB
/
run-extractor.yaml
File metadata and controls
138 lines (121 loc) · 5.92 KB
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
name: Run - Extractor
on:
workflow_dispatch:
inputs:
CONFIGURATION_YAML_PATH:
description: 'Choose Wether to extract all Apis or extract apis listed an extraction configuration file'
required: true
type: choice
options:
- Extract All APIs
- configuration.extractor.yaml
API_SPECIFICATION_FORMAT:
description: 'API Specification Format'
required: true
type: choice
options:
- OpenAPIV3Yaml
- OpenAPIV3Json
- OpenAPIV2Yaml
- OpenAPIV2Json
env:
apiops_release_version: v4.1.3
jobs:
extract:
runs-on: ubuntu-latest
environment: dev # change this to match the dev environment created in settings
steps:
- uses: actions/checkout@v3
- name: Run extractor without Config Yaml
if: ${{ github.event.inputs.CONFIGURATION_YAML_PATH == 'Extract All APIs' }}
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP_NAME: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
API_MANAGEMENT_SERVICE_NAME: ${{ secrets.API_MANAGEMENT_SERVICE_NAME }}
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ GITHUB.WORKSPACE }}/apimartifacts # change this to the artifacts folder
API_SPECIFICATION_FORMAT: ${{ github.event.inputs.API_SPECIFICATION_FORMAT }}
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$VerbosePreference = "Continue"
$InformationPreference = "Continue"
Write-Information "Downloading extractor..."
$extractorFileName = "${{ runner.os }}" -like "*win*" ? "extractor.win-x64.exe" : "extractor.linux-x64.exe"
$uri = "${{ vars.APIOPS_BINARY_FILES }}/${{ vars.APIOPS_RELEASE_VERSION }}/$extractorFileName"
$destinationFilePath = Join-Path "${{ runner.temp }}" "extractor.exe"
Invoke-WebRequest -Uri "$uri" -OutFile "$destinationFilePath"
if ("${{ runner.os }}" -like "*linux*")
{
Write-Information "Setting file permissions..."
& chmod +x "$destinationFilePath"
if ($LASTEXITCODE -ne 0) { throw "Setting file permissions failed."}
}
& "$destinationFilePath"
if ($LASTEXITCODE -ne 0) { throw "Running extractor failed."}
Write-Information "Execution complete."
shell: pwsh
- name: Run extractor with Config Yaml
if: ${{ github.event.inputs.CONFIGURATION_YAML_PATH != 'Extract All APIs' }}
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_RESOURCE_GROUP_NAME: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
API_MANAGEMENT_SERVICE_NAME: ${{ secrets.API_MANAGEMENT_SERVICE_NAME }}
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: ${{ GITHUB.WORKSPACE }}/apimartifacts # change this to the artifacts folder
API_SPECIFICATION_FORMAT: ${{ github.event.inputs.API_SPECIFICATION_FORMAT }}
CONFIGURATION_YAML_PATH: ${{ GITHUB.WORKSPACE }}/${{ github.event.inputs.CONFIGURATION_YAML_PATH }}
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$VerbosePreference = "Continue"
$InformationPreference = "Continue"
Write-Information "Downloading extractor..."
$extractorFileName = "${{ runner.os }}" -like "*win*" ? "extractor.win-x64.exe" : "extractor.linux-x64.exe"
$uri = "${{ vars.APIOPS_BINARY_FILES }}/${{ vars.APIOPS_RELEASE_VERSION }}/$extractorFileName"
$destinationFilePath = Join-Path "${{ runner.temp }}" "extractor.exe"
Invoke-WebRequest -Uri "$uri" -OutFile "$destinationFilePath"
if ("${{ runner.os }}" -like "*linux*")
{
Write-Information "Setting file permissions..."
& chmod +x "$destinationFilePath"
if ($LASTEXITCODE -ne 0) { throw "Setting file permissions failed."}
}
& "$destinationFilePath"
if ($LASTEXITCODE -ne 0) { throw "Running extractor failed."}
Write-Information "Execution complete."
shell: pwsh
- name: publish artifact
uses: actions/upload-artifact@v2
env:
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: apimartifacts # change this to the artifacts folder
with:
name: artifacts-from-portal
path: ${{ GITHUB.WORKSPACE }}/${{ env.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }}
create-pull-request:
needs: extract
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: Download artifacts-from-portal
uses: actions/download-artifact@v2
env:
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: apimartifacts # change this to the artifacts folder
with:
name: artifacts-from-portal
path: "${{ GITHUB.WORKSPACE }}/${{ env.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }}"
- name: Create artifacts pull request
uses: peter-evans/create-pull-request@v3
env:
API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH: apimartifacts # change this to the artifacts folder
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "updated extract from apim instance ${{ env.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }}"
title: "${{ env.API_MANAGEMENT_SERVICE_OUTPUT_FOLDER_PATH }} - extract"
body: >
This PR is auto-generated by Github actions workflow
labels: extract, automated pr