Skip to content

feat(cb2-8661): fix value type error #31

feat(cb2-8661): fix value type error

feat(cb2-8661): fix value type error #31

name: Tag Merge Conflicts
on:
push:
branches: ['develop']
pull_request:
branches: ['develop']
jobs:
merge-conflicts:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v6
with:
script: |
const pullRequests = (await github.rest.pulls.list({
...context.repo
})).data
const addMergeConflictTag = async (pullRequests) => {
const promises = pullRequests.map(pr => {
const { number } = pr
return github.rest.pulls.get({
...context.repo,
pull_number: number
})
})
const prs = await Promise.allSettled(promises)
const prsAwaitingCheck = []
prs.forEach(pr => {
const data = pr.value.data
if (data.mergeable === false) {
github.rest.issues.addLabels({
...context.repo,
issue_number: data.number,
labels: ["merge conflict"]
})
} else if (data.mergeable === true
&& data.labels.some(label => label.name === "merge conflict")) {
github.rest.issues.removeLabel({
...context.repo,
issue_number: data.number,
name: "merge conflict"
})
} else if (data.mergeable === null) {
prsAwaitingCheck.push({...data})
}
})
if (prsAwaitingCheck.length) {
console.log("Some PRs are still waiting to calculate status...")
await new Promise(resolve => setTimeout(resolve, 5000))
addMergeConflictTag(prsAwaitingCheck)
}
}
await addMergeConflictTag(pullRequests)