Skip to content

Commit

Permalink
chore: add GH workflow to automate projects (#1756)
Browse files Browse the repository at this point in the history
* Create project_automation.yml

* Create priority_bumper.yml
  • Loading branch information
div5yesh authored Jun 21, 2022
1 parent 216f243 commit a406343
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/priority_bumper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Projects priority automation
on:
issue_comment:
types: [created]

jobs:
bump_to_p2:
runs-on: ubuntu-latest
if: ${{ github.event.issue.comments > 10 }}
steps:
- name: Bump to P2
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
FIELD_ID: ${{ secrets.PRIORITY_COL }}
FIELD_OPT_ID: ${{ secrets.P2_OPT_ID }}
shell: bash
run: curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null

bump_to_p1:
runs-on: ubuntu-latest
if: ${{ github.event.issue.comments > 15 }}
steps:
- name: Bump to P1
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
FIELD_ID: ${{ secrets.PRIORITY_COL }}
FIELD_OPT_ID: ${{ secrets.P1_OPT_ID }}
shell: bash
run: curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null

50 changes: 50 additions & 0 deletions .github/workflows/project_automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Projects beta automation
on:
issues:
types: [opened, assigned, unassigned, labeled, unlabeled]

jobs:
add_issue:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'opened' }}
steps:
- name: Add to project
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
shell: bash
run: |
curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {addProjectNextItem(input:{projectId:\"${{ env.PROJECT_ID }}\" contentId:\"${{ env.ISSUE_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null
move_to_wip:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'assigned' || contains(github.event.issue.labels.*.name, 'pending-response') || contains(github.event.issue.labels.*.name, 'closing soon') }}
steps:
- name: Move to WIP column
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
FIELD_ID: ${{ secrets.STATUS_COL }}
FIELD_OPT_ID: ${{ secrets.WIP_OPT_ID }}
shell: bash
run: |
curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" —data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null
move_to_todo:
runs-on: ubuntu-latest
if: ${{ join(github.event.issue.assignees.*.login) == '' && !contains(github.event.issue.labels.*.name, 'pending-response') && !contains(github.event.issue.labels.*.name, 'closing soon') }}
steps:
- name: Move to Todo column
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_WORKFLOW_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
ISSUE_ID: ${{ github.event.issue.node_id }}
FIELD_ID: ${{ secrets.STATUS_COL }}
FIELD_OPT_ID: ${{ secrets.TODO_OPT_ID }}
shell: bash
run: |
curl -s POST https://api.github.com/graphql -H "Authorization:Bearer $GITHUB_TOKEN" --data '{"query":"mutation {updateProjectNextItemField(input:{projectId:\"${{ env.PROJECT_ID }}\" itemId:\"${{ env.ISSUE_ID }}\" fieldId:\"${{ env.FIELD_ID }}\" value:\"${{ env.FIELD_OPT_ID }}\"}) {projectNextItem {id}}}"}' > /dev/null

0 comments on commit a406343

Please sign in to comment.