11# This composite action updates Project V2 statuses after release work is closed.
22# Closed issues in status "Release" are moved to "Done".
3- # Closed pull requests in status "PRs" are moved to "Closed".
43# It also creates a release discussion and posts the link to Slack.
54name : Move issue to Done status
65description : ' Move issue'
3029 ORGANIZATION : ' equinor'
3130 PROJECT_NUMBER : 965
3231 # Uses [GitHub CLI](https://cli.github.com/manual/) to fetch:
33- # - closed issues and closed pull requests with their project item status
32+ # - closed issues with their project item status
3433 # - Project V2 field metadata and status option IDs
3534 # - repository IDs needed for discussion creation
3635 # The response is stored in `project_data.json`.
5554 number
5655 title
5756 }
58- ... on PullRequest {
59- __typename
60- number
61- title
62- }
6357 }
6458 fieldValueByName(name: "Status") {
6559 ... on ProjectV2ItemFieldSingleSelectValue {
7165 }
7266 }
7367 }
74- pullRequests(states: [CLOSED], first: 50, orderBy: { field: UPDATED_AT, direction: DESC }) {
75- nodes {
76- id
77- projectItems(first: 10, includeArchived: false) {
78- nodes {
79- id
80- content {
81- ... on Issue {
82- __typename
83- number
84- title
85- }
86- ... on PullRequest {
87- __typename
88- number
89- title
90- }
91- }
92- fieldValueByName(name: "Status") {
93- ... on ProjectV2ItemFieldSingleSelectValue {
94- status: name
95- }
96- }
97- }
98- }
99- }
100- }
10168 projectV2(number: $number) {
10269 id
10370 fields(first: 20) {
@@ -133,24 +100,19 @@ runs:
133100
134101 DONE_OPTION_ID=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name=="Status") | .options[] | select(.name=="Done") |.id' project_data.json)
135102 echo "DONE_OPTION_ID=${DONE_OPTION_ID}" >> $GITHUB_ENV
136-
137- CLOSED_OPTION_ID=$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name=="Status") | .options[] | select(.name=="Closed") |.id' project_data.json)
138- echo "CLOSED_OPTION_ID=${CLOSED_OPTION_ID}" >> $GITHUB_ENV
139-
140-
141103 DISCUSSION_CATEGORY_ID=$(jq -r '.data.organization.repository.discussionCategory.id' project_data.json)
142104 echo "DISCUSSION_CATEGORY_ID=${DISCUSSION_CATEGORY_ID}" >> $GITHUB_ENV
143105
144106 REPOSITORY_ID=$(jq -r '.data.organization.repository.id' project_data.json)
145107 echo "REPOSITORY_ID=${REPOSITORY_ID}" >> $GITHUB_ENV
146108
147- # Updates project item statuses based on content type and current status .
109+ # Updates issue project item statuses in "Release" to "Done" .
148110 - name : Set fields
149111 shell : bash
150112 env :
151113 GH_TOKEN : ${{ inputs.token }}
152114
153- # Sets the value of the `Status` field to `Done` for issues and `Closed` for pull requests .
115+ # Sets the value of the `Status` field to `Done` for issues.
154116 run : |
155117 ISSUE_ITEM_IDS=$(jq '.data.organization.repository.issues.nodes[].projectItems.nodes[] | select(.fieldValueByName.status =="Release" and .content.__typename == "Issue") | .id' project_data.json)
156118 echo "$ISSUE_ITEM_IDS"
@@ -177,32 +139,6 @@ runs:
177139 }
178140 }' -f project=$PROJECT_ID -f item=$id -f status_field=$STATUS_FIELD_ID -f status_value=$DONE_OPTION_ID --silent
179141 done
180-
181- PR_ITEM_IDS=$(jq '.data.organization.repository.pullRequests.nodes[].projectItems.nodes[] | select(.fieldValueByName.status =="PRs" and .content.__typename == "PullRequest") | .id' project_data.json)
182- echo "$PR_ITEM_IDS"
183- for id in $PR_ITEM_IDS; do
184- echo "Moving pull request $id to Closed ($CLOSED_OPTION_ID)"
185- gh api graphql -f query='
186- mutation (
187- $project: ID!
188- $item: ID!
189- $status_field: ID!
190- $status_value: String!
191- ) {
192- set_status: updateProjectV2ItemFieldValue(input: {
193- projectId: $project
194- itemId: $item
195- fieldId: $status_field
196- value: {
197- singleSelectOptionId: $status_value
198- }
199- }) {
200- projectV2Item {
201- id
202- }
203- }
204- }' -f project=$PROJECT_ID -f item=$id -f status_field=$STATUS_FIELD_ID -f status_value=$CLOSED_OPTION_ID --silent
205- done
206142 - name : Create discussion
207143 shell : bash
208144 env :
0 commit comments