From 3f312cefa7374450380e91cb9a5117e94bb0a5cb Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 10 Nov 2022 11:22:13 -0800 Subject: [PATCH] Add GitHub action for weekly preview OpenAPI docs refresh PR. (#1617) --- ...create-preview-openapidocs-pr-workflow.yml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/create-preview-openapidocs-pr-workflow.yml diff --git a/.github/workflows/create-preview-openapidocs-pr-workflow.yml b/.github/workflows/create-preview-openapidocs-pr-workflow.yml new file mode 100644 index 00000000000..5d869c1a599 --- /dev/null +++ b/.github/workflows/create-preview-openapidocs-pr-workflow.yml @@ -0,0 +1,54 @@ +# 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: "Create Weekly Preview OpenAPI Docs Refresh PR" +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the main branch +on: + push: + branches: + - 'WeeklyPreviewRefresh/*' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + createOpenApiDocsPR: + if: github.event_name == 'push' && contains(toJson(github.event.commits), '[run ci]') && !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 "GraphTooling@service.microsoft.com" + 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 Preview OpenAPI Docs Refresh + MESSAGE_BODY: "This pull request was automatically created by the GitHub Action,\n\n Contains OpenApi Docs Updates from Graph Explorer API (DevX API)" + REVIEWERS: peombwa,ddyett,timayabi2020,mairissi,shemogumbe + ASSIGNEDTO: peombwa + 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