Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for closed PRs #46

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/project_board_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ name: 'Project board automation'
pull_request_review_comment:
types: [created]

permissions:
repository-projects: write
contents: write
issues: write
pull-requests: write
permissions: write-all

# Configure the project specific varaibles
env:
Expand All @@ -30,6 +26,7 @@ env:
IN_REVIEW_COLUMN_NAME: '"IN_REVIEW"'
APPROVED_COLUMN_NAME: '"APPROVED"'
MERGED_COLUMN_NAME: '"MERGED"'
DONE_COLUMN_NAME: '"DONE"'
ITERATION_FIELD_NAME: Iteration # See project settings (default is `Iteration`)

jobs:
Expand Down Expand Up @@ -136,6 +133,7 @@ jobs:
echo 'IN_REVIEW_COLUMN='$(jq --arg in_review ${{ env.IN_REVIEW_COLUMN_NAME }} '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name==$in_review) |.id' data.json) >> $GITHUB_ENV
echo 'APPROVED_COLUMN='$(jq --arg approved ${{ env.APPROVED_COLUMN_NAME }} '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name==$approved) |.id' data.json) >> $GITHUB_ENV
echo 'MERGED_COLUMN='$(jq --arg merged ${{ env.MERGED_COLUMN_NAME }} '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name==$merged) |.id' data.json) >> $GITHUB_ENV
echo 'DONE_COLUMN='$(jq --arg merged ${{ env.DONE_COLUMN_NAME }} '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") |.settings | fromjson.options[] | select(.name==$merged) |.id' data.json) >> $GITHUB_ENV
echo 'ITERATION_FIELD_ID='$(jq --arg iteration_field_name $ITERATION_FIELD_NAME '.data.organization.projectNext.fields.nodes[] | select(.name==$iteration_field_name) | .id' data.json) >> $GITHUB_ENV
echo 'CURRENT_ITERATION='$(jq --arg iteration_field_name $ITERATION_FIELD_NAME '.data.organization.projectNext.fields.nodes[] | select(.name==$iteration_field_name) |.settings | fromjson.configuration.iterations[0] | .id' data.json) >> $GITHUB_ENV

Expand Down Expand Up @@ -281,7 +279,7 @@ jobs:
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.APPROVED_COLUMN }} >> $GITHUB_ENV

- name: 'Set work item for merged column'
- name: 'Set work item for merged column'
id: merged
if: env.PR_STATE == '"MERGED"' || github.event.pull_request.merged == true
run: |
Expand All @@ -301,6 +299,20 @@ jobs:
}
}' -f clientMutationId=$AUTHOR_ID -f issueId=$LINKED_ISSUE_ID

- name: 'Set closed PR for done column'
id: closed-pr
if: steps.exclude-linked.outcome == 'success' && github.event.pull_request.closed == true
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.DONE_COLUMN }} >> $GITHUB_ENV

- name: 'Set closed PR issue to in progress column'
id: closed-pr-with-issue
if: steps.linked.outcome == 'success' && github.event.pull_request.merged == true
run: |
echo 'ITEM_ID='${{ env.BOARD_ITEM_ID }} >> $GITHUB_ENV
echo 'CURRENT_STATUS='${{ env.IN_PROGRESS_COLUMN }} >> $GITHUB_ENV

#######
## Take the set item fields, update and move the item on the board
#######
Expand Down