mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update triage automation to use new project board and github projectV2 API
This commit is contained in:
parent
53a02fc130
commit
a6c809fd19
117
.github/workflows/triage.yml
vendored
117
.github/workflows/triage.yml
vendored
@ -6,55 +6,122 @@ on:
|
|||||||
- opened
|
- opened
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.PROJECT_BOARD_AUTOMATION }}
|
||||||
ORGANIZATION: ethereum
|
ORGANIZATION: ethereum
|
||||||
REPOSITORY: solidity
|
PROJECT_NUMBER: 27 # Solidity Bug Triaging Board
|
||||||
PROJECT_NUMBER: 43
|
# See: https://github.com/orgs/ethereum/projects/27/settings/fields/Status
|
||||||
DRY_RUN: false
|
COLUMN_FIELD_NAME: "Status"
|
||||||
|
TRIAGE_COLUMN_NAME: "To Triage"
|
||||||
|
DRY_RUN: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
triage_issues:
|
triage_issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Retrieve the content of all columns on the board
|
- name: Retrieve the content of selected field on the project board
|
||||||
run: |
|
run: |
|
||||||
gh api graphql \
|
gh api graphql \
|
||||||
--raw-field owner="$ORGANIZATION" \
|
--raw-field organization="$ORGANIZATION" \
|
||||||
--field project_number="$PROJECT_NUMBER" \
|
--field project_number="$PROJECT_NUMBER" \
|
||||||
--raw-field repository_name="$REPOSITORY" \
|
|
||||||
--raw-field query='
|
--raw-field query='
|
||||||
query($owner: String!, $repository_name: String!, $project_number: Int!) {
|
query($organization: String!, $project_number: Int!) {
|
||||||
repository(owner: $owner, name: $repository_name) {
|
organization(login: $organization) {
|
||||||
project(number: $project_number) {
|
projectV2(number: $project_number) {
|
||||||
columns(first: 10) {
|
id
|
||||||
|
fields(first: 20) {
|
||||||
nodes {
|
nodes {
|
||||||
id,
|
... on ProjectV2Field {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
... on ProjectV2SingleSelectField {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
options {
|
||||||
|
id
|
||||||
name
|
name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}' > project_columns.json
|
}
|
||||||
echo 'COLUMN_ID='$(jq '.data.repository.project.columns.nodes[] | select(.name == "Triage") | .id' project_columns.json) >> $GITHUB_ENV
|
}
|
||||||
echo 'COLUMN_NAME='$(jq '.data.repository.project.columns.nodes[] | select(.name == "Triage") | .name' project_columns.json) >> $GITHUB_ENV
|
}' > single_select_fields.json
|
||||||
|
echo 'PROJECT_ID='$(
|
||||||
|
jq \
|
||||||
|
'.data.organization.projectV2.id' \
|
||||||
|
single_select_fields.json
|
||||||
|
) >> $GITHUB_ENV
|
||||||
|
echo 'COLUMN_FIELD_ID='$(
|
||||||
|
jq \
|
||||||
|
--arg column_field_name "$COLUMN_FIELD_NAME" \
|
||||||
|
'.data.organization.projectV2.fields.nodes[]
|
||||||
|
| select(.name == $column_field_name)
|
||||||
|
| .id' \
|
||||||
|
single_select_fields.json
|
||||||
|
) >> $GITHUB_ENV
|
||||||
|
echo 'TRIAGE_COLUMN_ID='$(
|
||||||
|
jq --raw-output \
|
||||||
|
--arg column_field_name "$COLUMN_FIELD_NAME" \
|
||||||
|
--arg triage_column_name "$TRIAGE_COLUMN_NAME" \
|
||||||
|
'.data.organization.projectV2.fields.nodes[]
|
||||||
|
| select(.name == $column_field_name)
|
||||||
|
| .options[]
|
||||||
|
| select(.name == $triage_column_name)
|
||||||
|
| .id' \
|
||||||
|
single_select_fields.json
|
||||||
|
) >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Add issue#${{ github.event.issue.number }} to Triage column
|
- name: Add issue#${{ github.event.issue.number }} to project
|
||||||
env:
|
env:
|
||||||
ISSUE_ID: ${{ github.event.issue.node_id }}
|
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||||
run: |
|
run: |
|
||||||
echo "Adding issue: ${{ github.event.issue.number }} to column $COLUMN_NAME in project $PROJECT_NUMBER"
|
echo "Adding issue: ${{ github.event.issue.number }} to project ${{ env.PROJECT_NUMBER }}"
|
||||||
if [[ $DRY_RUN == "false" ]]; then
|
if [[ $DRY_RUN == 'false' ]]; then
|
||||||
|
echo 'ITEM_ID='$(
|
||||||
|
gh api graphql \
|
||||||
|
--jq '.data.addProjectV2ItemById.item.id' \
|
||||||
|
--raw-field project_id="$PROJECT_ID" \
|
||||||
|
--raw-field issue_id="$ISSUE_ID" \
|
||||||
|
--raw-field query='
|
||||||
|
mutation($project_id: ID!, $issue_id: ID!) {
|
||||||
|
addProjectV2ItemById(input: {projectId: $project_id, contentId: $issue_id}) {
|
||||||
|
item {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
) >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Move issue#${{ github.event.issue.number }} to Triage column
|
||||||
|
run: |
|
||||||
|
echo "Moving issue: ${{ github.event.issue.number }} to Triage column in project ${{ env.PROJECT_NUMBER }}"
|
||||||
|
if [[ $DRY_RUN == 'false' ]]; then
|
||||||
gh api graphql \
|
gh api graphql \
|
||||||
--silent \
|
--silent \
|
||||||
--raw-field column=$COLUMN_ID \
|
--raw-field project_id="$PROJECT_ID" \
|
||||||
--raw-field issue=$ISSUE_ID \
|
--raw-field item_id="$ITEM_ID" \
|
||||||
|
--raw-field column_field_id="$COLUMN_FIELD_ID" \
|
||||||
|
--raw-field column_value_id="$TRIAGE_COLUMN_ID" \
|
||||||
--raw-field query='
|
--raw-field query='
|
||||||
mutation($column: ID!, $issue: ID!) {
|
mutation (
|
||||||
addProjectCard(input: {
|
$project_id: ID!
|
||||||
projectColumnId: $column,
|
$item_id: ID!
|
||||||
contentId: $issue
|
$column_field_id: ID!
|
||||||
|
$column_value_id: String!
|
||||||
|
) {
|
||||||
|
updateProjectV2ItemFieldValue(input: {
|
||||||
|
projectId: $project_id
|
||||||
|
itemId: $item_id
|
||||||
|
fieldId: $column_field_id
|
||||||
|
value: {
|
||||||
|
singleSelectOptionId: $column_value_id
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
clientMutationId
|
projectV2Item {
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user