|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | +# This is a basic workflow to help you get started with Actions |
| 4 | + |
| 5 | +name: "Create Weekly Preview OpenAPI Docs Refresh PR" |
| 6 | +# Controls when the action will run. Triggers the workflow on push or pull request |
| 7 | +# events but only for the main branch |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - 'WeeklyPreviewRefresh/*' |
| 12 | + |
| 13 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 14 | +jobs: |
| 15 | + createOpenApiDocsPR: |
| 16 | + 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]') |
| 17 | + # The type of runner that the job will run on |
| 18 | + runs-on: ubuntu-latest |
| 19 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 20 | + steps: |
| 21 | + - name: Configure User |
| 22 | + run: | |
| 23 | + git config --global user.email "[email protected]" |
| 24 | + git config --global user.name "Microsoft Graph DevX Tooling" |
| 25 | +
|
| 26 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v2 |
| 29 | + |
| 30 | + - name: List Directory |
| 31 | + run: | |
| 32 | + echo $GITHUB_WORKSPACE |
| 33 | + ls -lsa $GITHUB_WORKSPACE |
| 34 | + ls -lsa $GITHUB_WORKSPACE/tools |
| 35 | +
|
| 36 | + # Create a pull request [1] |
| 37 | + - name: Create PR using the GitHub REST API via hub |
| 38 | + shell: bash |
| 39 | + env: |
| 40 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + MESSAGE_TITLE: Weekly Preview OpenAPI Docs Refresh |
| 42 | + MESSAGE_BODY: "This pull request was automatically created by the GitHub Action,\n\n Contains OpenApi Docs Updates from Graph Explorer API (DevX API)" |
| 43 | + REVIEWERS: peombwa,ddyett,timayabi2020,mairissi,shemogumbe |
| 44 | + ASSIGNEDTO: peombwa |
| 45 | + LABELS: generated |
| 46 | + BASE: dev |
| 47 | + HEAD: ${{steps.create_branch.outputs.branch}} |
| 48 | + run: | |
| 49 | + curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1 |
| 50 | + bin/hub pull-request -b "$BASE" -h "$HEAD" -m "$MESSAGE_TITLE" -m "$MESSAGE_BODY" -r "$REVIEWERS" -a "$ASSIGNEDTO" -l "$LABELS" |
| 51 | +# References |
| 52 | +# [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables |
| 53 | +# [1] https://hub.github.com/hub-pull-request.1.html |
| 54 | +# https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token |
0 commit comments