2021-11-11 14:09:01 -05:00
|
|
|
name: Add PR to Board
|
|
|
|
|
|
|
|
on:
|
2021-12-31 09:50:30 -05:00
|
|
|
pull_request_target:
|
2021-12-31 12:32:42 -05:00
|
|
|
types: [opened, synchronize, ready_for_review, review_requested]
|
2021-11-11 14:09:01 -05:00
|
|
|
|
|
|
|
jobs:
|
2021-12-31 09:50:30 -05:00
|
|
|
track_pr:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Get project data
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
|
|
|
run: |
|
|
|
|
gh api graphql -f query='
|
|
|
|
query {
|
|
|
|
organization(login: "revoltchat"){
|
2023-01-24 14:43:32 -05:00
|
|
|
projectV2(number: 3) {
|
2021-12-31 09:50:30 -05:00
|
|
|
id
|
|
|
|
fields(first:20) {
|
|
|
|
nodes {
|
2023-01-24 14:43:32 -05:00
|
|
|
... on ProjectV2SingleSelectField {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
options {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
}
|
|
|
|
}
|
2021-12-31 09:50:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}' > project_data.json
|
2021-11-11 14:09:01 -05:00
|
|
|
|
2023-01-24 14:43:32 -05:00
|
|
|
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
|
|
|
|
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
|
|
|
echo 'INCOMING_OPTION_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Status") | .options[] | select(.name=="Incoming PRs") |.id' project_data.json) >> $GITHUB_ENV
|
2021-11-11 14:09:01 -05:00
|
|
|
|
2021-12-31 09:50:30 -05:00
|
|
|
- name: Add PR to project
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
|
|
|
PR_ID: ${{ github.event.pull_request.node_id }}
|
|
|
|
run: |
|
|
|
|
item_id="$( gh api graphql -f query='
|
|
|
|
mutation($project:ID!, $pr:ID!) {
|
2023-01-24 14:43:32 -05:00
|
|
|
addProjectV2ItemById(input: {projectId: $project, contentId: $pr}) {
|
|
|
|
item {
|
2021-12-31 09:50:30 -05:00
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
2023-01-24 14:43:32 -05:00
|
|
|
}' -f project=$PROJECT_ID -f pr=$PR_ID --jq '.data.addProjectV2ItemById.item.id')"
|
|
|
|
|
2021-12-31 09:50:30 -05:00
|
|
|
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
2021-11-11 14:09:01 -05:00
|
|
|
|
2021-12-31 09:50:30 -05:00
|
|
|
- name: Set fields
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.PAT }}
|
|
|
|
run: |
|
|
|
|
gh api graphql -f query='
|
|
|
|
mutation (
|
|
|
|
$project: ID!
|
|
|
|
$item: ID!
|
|
|
|
$status_field: ID!
|
|
|
|
$status_value: String!
|
|
|
|
) {
|
2023-01-24 14:43:32 -05:00
|
|
|
set_status: updateProjectV2ItemFieldValue(input: {
|
2021-12-31 09:50:30 -05:00
|
|
|
projectId: $project
|
|
|
|
itemId: $item
|
|
|
|
fieldId: $status_field
|
2023-01-24 14:43:32 -05:00
|
|
|
value: {
|
|
|
|
singleSelectOptionId: $status_value
|
|
|
|
}
|
2021-12-31 09:50:30 -05:00
|
|
|
}) {
|
2023-01-24 14:43:32 -05:00
|
|
|
projectV2Item {
|
2021-12-31 09:50:30 -05:00
|
|
|
id
|
2023-01-24 14:43:32 -05:00
|
|
|
}
|
2021-12-31 09:50:30 -05:00
|
|
|
}
|
|
|
|
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=${{ env.INCOMING_OPTION_ID }} --silent
|