-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
108 changed files
with
217 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
# Generates a release build artifact (nuget) from HEAD of master for auth module. | ||
name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) | ||
|
||
pool: | ||
vmImage: "windows-latest" | ||
|
||
variables: | ||
BRANCH: 'weeklyOpenApiDocsDownload' | ||
GitUserEmail: '[email protected]' | ||
GitUserName: 'Microsoft Graph DevX Tooling' | ||
BaseBranch: 'dev' | ||
|
||
schedules: | ||
- cron: "0 0 * * WED" # Run Every Wednesday | ||
displayName: "Weekly OpenApiDocs Download and PR" | ||
branches: | ||
include: | ||
- dev | ||
always: true | ||
|
||
steps: | ||
- checkout: self | ||
persistCredentials: true | ||
clean: true | ||
fetchDepth: 1 | ||
|
||
- task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 | ||
displayName: 'Run CredScan' | ||
inputs: | ||
debugMode: false | ||
|
||
- task: PowerShell@2 | ||
displayName: "Compute Branch" | ||
inputs: | ||
targetType: inline | ||
script: | | ||
$branch = "{0}.{1}" -f "weeklyOpenApiDocsDownload", (Get-Date -Format yyyyMMdd) | ||
Write-Host "##vso[task.setvariable variable=BRANCH;]$branch" | ||
- task: PowerShell@2 | ||
displayName: "Configure User" | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
git config --global user.email '$(GitUserEmail)' | ||
git config --global user.name '$(GitUserName)' | ||
- task: PowerShell@2 | ||
displayName: "Show Directory" | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
ls $(System.DefaultWorkingDirectory) | ||
ls $(System.DefaultWorkingDirectory)/tools | ||
- task: PowerShell@2 | ||
displayName: Download v1.0 OpenApiDocs | ||
inputs: | ||
filePath: '$(System.DefaultWorkingDirectory)/tools/UpdateOpenApi.ps1' | ||
pwsh: true | ||
|
||
- task: PowerShell@2 | ||
displayName: Download beta OpenApiDocs | ||
inputs: | ||
filePath: '$(System.DefaultWorkingDirectory)/tools/UpdateOpenApi.ps1' | ||
arguments: '-BetaGraphVersion' | ||
pwsh: true | ||
|
||
- task: Bash@3 | ||
displayName : "Create PR $(BRANCH)" | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
git status | ||
git checkout $(BaseBranch) | ||
git branch $(BRANCH) | ||
git checkout $(BRANCH) | ||
git status | ||
- task: Bash@3 | ||
displayName : "Commit Downloaded Files" | ||
env: | ||
GITHUB_TOKEN: $(GITHUB_TOKEN) | ||
inputs: | ||
targetType: 'inline' | ||
script: | | ||
git status | ||
git add . | ||
git commit -m 'Weekly OpenApiDocs Download' | ||
git status | ||
git push --set-upstream origin $(BRANCH) | ||
git status | ||
# References | ||
# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables | ||
# [1] https://hub.github.com/hub-pull-request.1.html | ||
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: WeeklyOpenApiDocsDownload | ||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
branches: | ||
- 'weeklyOpenApiDocsDownload.*' | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
downloadOpenApiDocs: | ||
if: github.event_name == 'push' && !contains(toJson(github.event.commits), 'NO_CI') && !contains(toJson(github.event.commits), '[ci skip]') && !contains(toJson(github.event.commits), '[skip ci]') | ||
# The type of runner that the job will run on | ||
runs-on: ubuntu-latest | ||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
- name: Configure User | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Microsoft Graph DevX Tooling" | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: List Directory | ||
run: | | ||
echo $GITHUB_WORKSPACE | ||
ls -lsa $GITHUB_WORKSPACE | ||
ls -lsa $GITHUB_WORKSPACE/tools | ||
# Create a pull request [1] | ||
- name: Create PR using the GitHub REST API via hub | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
MESSAGE_TITLE: Weekly OpenApiDocs Download | ||
MESSAGE_BODY: "This pull request was automatically created by the GitHub Action,\n\n Contains OpenApiDocs Updates from Graph Explorer API" | ||
REVIEWERS: peombwa,ddyett,darrelmiller | ||
ASSIGNEDTO: finsharp | ||
LABELS: generated | ||
BASE: dev | ||
HEAD: ${{steps.create_branch.outputs.branch}} | ||
run: | | ||
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 | ||
bin/hub pull-request -b "$BASE" -h "$HEAD" -m "$MESSAGE_TITLE" -m "$MESSAGE_BODY" -r "$REVIEWERS" -a "$ASSIGNEDTO" -l "$LABELS" | ||
# References | ||
# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables | ||
# [1] https://hub.github.com/hub-pull-request.1.html | ||
# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
Param( | ||
[string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"), | ||
[string] $OpenApiDocOutput = (Join-Path $PSScriptRoot "..\openApiDocs"), | ||
[switch] $BetaGraphVersion | ||
) | ||
|
||
$ErrorActionPreference = 'Stop' | ||
$LASTEXITCODE = $null | ||
if ($PSEdition -ne 'Core') { | ||
Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' | ||
} | ||
# Install Powershell-yaml | ||
Install-Module powershell-yaml -Force | ||
|
||
$GraphVersion = "v1.0" | ||
if ($BetaGraphVersion) { | ||
$GraphVersion = "beta" | ||
} | ||
|
||
$OpenApiDocOutput = Join-Path $OpenApiDocOutput $GraphVersion | ||
|
||
# PS Scripts | ||
$DownloadOpenApiDocPS1 = Join-Path $PSScriptRoot ".\DownloadOpenApiDoc.ps1" -Resolve | ||
|
||
if (-not (Test-Path $ModuleMappingConfigPath)) { | ||
Write-Error "Module mapping file not be found: $ModuleMappingConfigPath." | ||
} | ||
|
||
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable | ||
$ModuleMapping.Keys | ForEach-Object -Begin { $RequestCount = 0 } -End { Write-Host -ForeGroundColor Green "Requests: $RequestCount" } -Process { | ||
$ModuleName = $_ | ||
try { | ||
# Download OpenAPI document for module. | ||
& $DownloadOpenApiDocPS1 -ModuleName $ModuleName -ModuleRegex $ModuleMapping[$ModuleName] -OpenApiDocOutput $OpenApiDocOutput -GraphVersion $GraphVersion -RequestCount $RequestCount | ||
} | ||
catch { | ||
Write-Error $_.Exception | ||
} | ||
$RequestCount = $RequestCount + 1 | ||
} | ||
|
||
|
||
Write-Host -ForegroundColor Green "-------------Done-------------" |