Track release blockers in Matrix room header (#25427)
							parent
							
								
									6b7f71f973
								
							
						
					
					
						commit
						3c7a9933b9
					
				|  | @ -11,6 +11,7 @@ jobs: | |||
|         environment: Matrix | ||||
|         env: | ||||
|             URL: "https://github.com/pulls?q=is%3Apr+is%3Aopen+repo%3Amatrix-org%2Fmatrix-js-sdk+repo%3Amatrix-org%2Fmatrix-react-sdk+repo%3Avector-im%2Felement-web+repo%3Avector-im%2Felement-desktop+review-requested%3A%40me+sort%3Aupdated-desc+" | ||||
|             RELEASE_BLOCKERS_URL: "https://github.com/pulls?q=is%3Aopen+repo%3Amatrix-org%2Fmatrix-js-sdk+repo%3Amatrix-org%2Fmatrix-react-sdk+repo%3Avector-im%2Felement-web+repo%3Avector-im%2Felement-desktop+sort%3Aupdated-desc+label%3AX-Release-Blocker+" | ||||
|         steps: | ||||
|             - uses: actions/github-script@v6 | ||||
|               env: | ||||
|  | @ -21,6 +22,43 @@ jobs: | |||
|                   # PAT needed as the GITHUB_TOKEN won't be able to see cross-references from other orgs (matrix-org) | ||||
|                   github-token: ${{ secrets.ELEMENT_BOT_TOKEN }} | ||||
|                   script: | | ||||
|                       const { HS_URL, ROOM_ID, TOKEN, URL, RELEASE_BLOCKERS_URL } = process.env; | ||||
| 
 | ||||
|                       async function updateCounter(counter, link, severity, title, value, clearOnZero) { | ||||
|                           const apiUrl = `${HS_URL}/_matrix/client/v3/rooms/${ROOM_ID}/state/re.jki.counter/${counter}`; | ||||
|                           const headers = { | ||||
|                               "Content-Type": "application/json", | ||||
|                               "Authorization": `Bearer ${TOKEN}`, | ||||
|                           }; | ||||
|                           const res = await fetch(apiUrl, { | ||||
|                               method: "GET", | ||||
|                               headers, | ||||
|                           }); | ||||
| 
 | ||||
|                           const data = await res.json(); | ||||
| 
 | ||||
|                           if (data.value === issueCount) { | ||||
|                               console.log("Pending review count already correct"); | ||||
|                               return; | ||||
|                           } | ||||
| 
 | ||||
|                           let body = {}; | ||||
|                           if (issueCount || !clearOnZero) { | ||||
|                               body = JSON.stringify({ | ||||
|                                   link, | ||||
|                                   severity, | ||||
|                                   title, | ||||
|                                   value, | ||||
|                               }); | ||||
|                           } | ||||
| 
 | ||||
|                           await fetch(apiUrl, { | ||||
|                               method: "PUT", | ||||
|                               body, | ||||
|                               headers, | ||||
|                           }); | ||||
|                       } | ||||
| 
 | ||||
|                       const repos = [ | ||||
|                           "vector-im/element-desktop", | ||||
|                           "vector-im/element-web", | ||||
|  | @ -43,32 +81,10 @@ jobs: | |||
|                           }); | ||||
|                           issueCount += data.total_count; | ||||
|                       } | ||||
|                       await updateCounter("gh_reviews", URL, "warning", "Pending reviews", issueCount); | ||||
| 
 | ||||
|                       const { HS_URL, ROOM_ID, TOKEN, URL } = process.env; | ||||
|                       const apiUrl = `${HS_URL}/_matrix/client/v3/rooms/${ROOM_ID}/state/re.jki.counter/gh_reviews`; | ||||
|                       const headers = { | ||||
|                           "Content-Type": "application/json", | ||||
|                           "Authorization": `Bearer ${TOKEN}`, | ||||
|                       }; | ||||
|                       const res = await fetch(apiUrl, { | ||||
|                           method: "GET", | ||||
|                           headers, | ||||
|                       }); | ||||
| 
 | ||||
|                       const data = await res.json(); | ||||
| 
 | ||||
|                       if (data.value === issueCount) { | ||||
|                           console.log("Pending review count already correct"); | ||||
|                           return; | ||||
|                       } | ||||
| 
 | ||||
|                       await fetch(apiUrl, { | ||||
|                           method: "PUT", | ||||
|                           body: JSON.stringify({ | ||||
|                               "link": URL, | ||||
|                               "severity": "warning", | ||||
|                               "title": "Pending reviews", | ||||
|                               "value": issueCount | ||||
|                           }), | ||||
|                           headers, | ||||
|                       const { data } = await github.rest.search.issuesAndPullRequests({ | ||||
|                           q: `is:open ${repo.map(r => `repo:${r}`).join(" ")}`, | ||||
|                       }); | ||||
|                       const blockerCount = data.total_count; | ||||
|                       await updateCounter("release_blockers", "error", RELEASE_BLOCKERS_URL, "Release Blockers", blockerCount, true); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Michael Telatynski
						Michael Telatynski