Skip to content

Commit

Permalink
Update triage github actions workflow (#355)
Browse files Browse the repository at this point in the history
Update the triage github actions workflow to use the shared implementation.
This allows us to just change the shared workflow when it needs updated,
rather than having to update each and every repository.
  • Loading branch information
benfred authored Sep 8, 2022
1 parent 6d53898 commit 476dce7
Showing 1 changed file with 4 additions and 127 deletions.
131 changes: 4 additions & 127 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,130 +5,7 @@ on:

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
uses: nvidia-merlin/.github/.github/workflows/triage.yaml@main
secrets:
TRIAGE_APP_ID: ${{ secrets.TRIAGE_APP_ID }}
TRIAGE_APP_PEM: ${{ secrets.TRIAGE_APP_PEM }}

0 comments on commit 476dce7

Please sign in to comment.