PromucFlow_constructor/.github/workflows/close-labeler.yml
Arpit Mohan 6aeb456c62
ci: Upgrade GitHub Action steps to github-script@v7 and pload-artifact@v4 (#33554)
## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No

---------

Co-authored-by: yatinappsmith <84702014+yatinappsmith@users.noreply.github.com>
2024-05-20 10:49:27 +05:30

71 lines
2.2 KiB
YAML

name: Close Labeler
on:
pull_request:
types:
- closed
branches:
- release
jobs:
apply:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.CLOSE_LABELER_GITHUB_TOKEN }}
script: |
console.log("PR Details", context.issue)
const result = await github.graphql(
`
query($owner: String!, $name: String!, $prNum: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $prNum) {
closingIssuesReferences(first: 10) {
nodes {
number
repository {
name
owner {
login
}
}
labels(first: 50) {
edges {
node {
name
}
}
}
}
}
}
}
}
`,
{
owner: context.issue.owner,
name: context.issue.repo,
prNum: context.issue.number,
},
)
console.log("GraphQL result", JSON.stringify(result, null, 2));
for (const node of result.repository.pullRequest.closingIssuesReferences.nodes) {
const shouldQA = node.labels.edges.find(edge => edge.node.name === "Enhancement" || edge.node.name === "Bug") != null
if (!shouldQA) {
break
}
console.log("Adding QA to", node.repository.owner.login, node.repository.name, node.number)
github.rest.issues.addLabels({
issue_number: node.number,
owner: node.repository.owner.login,
repo: node.repository.name,
labels: ["QA"],
})
}
console.log("Fin")