Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
peombwa authored Jun 4, 2020
2 parents 5930fed + 40ccdd8 commit ae2cc81
Show file tree
Hide file tree
Showing 108 changed files with 217 additions and 4 deletions.
100 changes: 100 additions & 0 deletions .azure-pipelines/download-openapidocs.yml
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
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
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.
Empty file added openApiDocs/v1.0/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions src/Beta/Sites.Site/Sites.Site/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ directive:
variant: CreateViaIdentityExpanded
set:
subject: SubSite
- where:
parameter-name: SiteId
verb: Get
subject: (SiteAnalytic|SiteColumn|SiteContentType|SiteContentTypeContentLink|SubSite)
set:
default:
name: SiteId Default Value
description: Get the SiteId as default to root
script: '"root"'
```
### Versioning
Expand Down
12 changes: 8 additions & 4 deletions tools/DownloadOpenApiDoc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ Param(
[string] $ModuleName,
[string] $ModuleRegex,
[string] $OpenApiDocOutput,
[string] $GraphVersion
[string] $GraphVersion,
[int] $RequestCount
)

if(-not (Test-Path $OpenApiDocOutput)) {
if (-not (Test-Path $OpenApiDocOutput)) {
New-Item -Path $OpenApiDocOutput -Type Directory
}

$OpenApiBaseUrl = "https://graphexplorerapi.azurewebsites.net"
$OpenApiServiceUrl = ("$OpenApiBaseUrl/`$openapi?tags={0}&title=$ModuleName&openapiversion=3&style=Powershell&graphVersion=$GraphVersion" -f $ModuleRegex)
if ($RequestCount -eq 0) {
$OpenApiServiceUrl = "$OpenApiServiceUrl&forceRefresh=true"
}

Write-Host -ForegroundColor Green "Downloading OpenAPI doc for '$ModuleName' module: $OpenApiServiceUrl"
Write-Host -ForegroundColor Green "[$RequestCount] Downloading OpenAPI doc for '$ModuleName' module: $OpenApiServiceUrl"
Invoke-WebRequest $OpenApiServiceUrl -OutFile "$OpenApiDocOutput\$ModuleName.yml"
45 changes: 45 additions & 0 deletions tools/UpdateOpenApi.ps1
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-------------"

0 comments on commit ae2cc81

Please sign in to comment.