-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github workflow to automatically add new issues to backlog (#156)
* Add github workflow to automatically add new issues to backlog * Trigger pre-commit Co-authored-by: Marc Romeyn <[email protected]>
- Loading branch information
1 parent
0c71a7f
commit 1ebae3d
Showing
1 changed file
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
name: triage_issues | ||
on: | ||
issues: | ||
types: [opened, reopened] | ||
|
||
jobs: | ||
triage_issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@36464acb844fc53b9b8b2401da68844f6b05ebb0 | ||
with: | ||
app_id: ${{ secrets.TRIAGE_APP_ID }} | ||
private_key: ${{ secrets.TRIAGE_APP_PEM }} | ||
|
||
- name: Get project data | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
ORGANIZATION: NVIDIA-Merlin | ||
PROJECT_NUMBER: 6 | ||
run: | | ||
gh api graphql -f query=' | ||
query($org: String!, $number: Int!) { | ||
organization(login: $org){ | ||
projectNext(number: $number) { | ||
id | ||
fields(first:20) { | ||
nodes { | ||
id | ||
name | ||
settings | ||
} | ||
} | ||
} | ||
} | ||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json | ||
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV | ||
echo 'DATE_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Date Added") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'PRIORITY_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Priority") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'IMPACT_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Impact") | .id' project_data.json) >> $GITHUB_ENV | ||
echo 'NEEDS_TRIAGE_OPTION_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Priority") |.settings | fromjson.options[] | select(.name=="Needs Triage") |.id' project_data.json) >> $GITHUB_ENV | ||
- name: Add Issue to Project | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
ISSUE_ID: ${{ github.event.issue.node_id }} | ||
run: | | ||
item_id="$( gh api graphql -f query=' | ||
mutation($project:ID!, $issue:ID!) { | ||
addProjectNextItem(input: {projectId: $project, contentId: $issue}) { | ||
projectNextItem { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')" | ||
echo 'ITEM_ID='$item_id >> $GITHUB_ENV | ||
- name: Get date | ||
run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV | ||
|
||
- name: Checking if issue created by a Merlin team member | ||
id: check_internal | ||
continue-on-error: true | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
USERNAME: ${{ github.actor }} | ||
run: | | ||
echo "Checking if $USERNAME is a member of NVIDIA-Merlin" | ||
gh api orgs/NVIDIA-Merlin/members/$USERNAME | ||
echo "$USERNAME is a member of NVIDIA-Merlin" | ||
- name: Set Impact for external users | ||
if: steps.check_internal.outcome=='failure' | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
USERNAME: ${{ github.actor }} | ||
run: | | ||
echo "$USERNAME is not member of NVIDIA-Merlin - setting impact to External" | ||
gh api graphql -f query=' | ||
mutation ( | ||
$project: ID! | ||
$item: ID! | ||
$impact_field: ID! | ||
$impact_value: String! | ||
) { | ||
set_priority: updateProjectNextItemField(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $impact_field | ||
value: $impact_value | ||
}) { | ||
projectNextItem { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f impact_field=$IMPACT_FIELD_ID -f impact_value=External --silent | ||
- name: Set fields | ||
env: | ||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | ||
run: | | ||
gh api graphql -f query=' | ||
mutation ( | ||
$project: ID! | ||
$item: ID! | ||
$priority_field: ID! | ||
$priority_value: String! | ||
$date_field: ID! | ||
$date_value: String! | ||
) { | ||
set_priority: updateProjectNextItemField(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $priority_field | ||
value: $priority_value | ||
}) { | ||
projectNextItem { | ||
id | ||
} | ||
} | ||
set_date_posted: updateProjectNextItemField(input: { | ||
projectId: $project | ||
itemId: $item | ||
fieldId: $date_field | ||
value: $date_value | ||
}) { | ||
projectNextItem { | ||
id | ||
} | ||
} | ||
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f priority_field=$PRIORITY_FIELD_ID -f priority_value=${{ env.NEEDS_TRIAGE_OPTION_ID }} -f date_field=$DATE_FIELD_ID -f date_value=$DATE --silent |