Skip to content

Commit

Permalink
Add PR automation for project boards
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhua authored and manojsdoshi committed Apr 24, 2020
1 parent 023f570 commit cd78ce3
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/pr_automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: PR automation
on:
pull_request:
types: [labeled, unlabeled]

jobs:
job:
runs-on: ubuntu-latest
steps:
- name: retrieve label
run: |
jq '.' $GITHUB_EVENT_PATH
LABEL_NAME1=$(jq --raw-output ".label.name" $GITHUB_EVENT_PATH)
echo "Label in action is $LABEL_NAME1"
echo ::set-env name=LABEL_NAME::$LABEL_NAME1
#inspect the PR to get the project name
- name: retrieve project name
uses: octokit/[email protected]
id: get_project_name
with:
query: |
query get_project_name($owner:String!, $repo:String!, $number:Int!) {
repository(owner:$owner,name:$repo) {
pullRequest(number: $number) {
projectCards(first: 1) {
nodes {
project {
name
}
}
}
}
}
}
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
number: ${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: extract
uses: gr2m/[email protected]
with:
json: ${{ steps.get_project_name.outputs.data }}
name: "repository.pullRequest.projectCards.nodes[0].project.name"
- name: echo project name
run: "echo project name: ${{ steps.extract.outputs.name }}, action: ${{ github.event.action }}"
- name: perform automation for label
if: env.LABEL_NAME == 'Passed' && steps.extract.outputs.name != '' && github.event.action == 'labeled'
uses: alex-page/[email protected]
with:
project: ${{ steps.extract.outputs.name }}
#if we change the column name, this automation needs to be updated
column: 'Approved for Merging'
repo-token: ${{ secrets.PR_TOKEN }}
- name: perform automation for unlabel
if: env.LABEL_NAME == 'Passed' && steps.extract.outputs.name != '' && github.event.action == 'unlabeled'
uses: alex-page/[email protected]
with:
project: ${{ steps.extract.outputs.name }}
column: 'In Review'
repo-token: ${{ secrets.PR_TOKEN }}

0 comments on commit cd78ce3

Please sign in to comment.