Skip to content

Commit

Permalink
Add GitHub action for weekly preview OpenAPI docs refresh PR. (#1617)
Browse files Browse the repository at this point in the history
  • Loading branch information
peombwa authored Nov 10, 2022
1 parent 1be2514 commit 3f312ce
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/create-preview-openapidocs-pr-workflow.yml
Original file line number Diff line number Diff line change
@@ -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 "[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 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

0 comments on commit 3f312ce

Please sign in to comment.