Bugfix/turbo mem leak #4159
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: '[gh] pull review notification' | |
on: | |
pull_request_target: | |
types: [ review_requested ] | |
workflow_run: | |
workflows: | |
- \[gh\] pull request review | |
types: [ completed ] | |
jobs: | |
review_requested_notification: | |
if: github.repository == 'Tencent/Hippy' && github.event.action == 'review_requested' && github.event.requested_reviewer.type == 'User' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notice | |
uses: actions/github-script@v6.3.3 | |
env: | |
MESSAGE: | | |
[${{ github.event.sender.login }}](https://github.com/${{ github.event.sender.login }}) requested your review on [#${{ github.event.pull_request.number }}](${{ github.event.pull_request.html_url }}) pull request. | |
> ${{ github.event.pull_request.title }} | |
> [${{ github.event.pull_request.html_url }}](${{ github.event.pull_request.html_url }}) | |
> [%s changed files](${{ github.event.pull_request.html_url }}/files) with <font color="info">%s additions</font> and <font color="warning">%s deletions</font> | |
WECHAT_WORK_USERS: ${{ secrets.WECHAT_WORK_USERS }} | |
with: | |
script: | | |
const { format } = require("util"); | |
const userid = JSON.parse(process.env.WECHAT_WORK_USERS)["${{ github.event.requested_reviewer.login }}"]; | |
if (!userid) { | |
console.log("The reviewer ${{ github.event.requested_reviewer.login }} not found in secrets.WECHAT_WORK_USERS"); | |
return; | |
} | |
await github.request("POST ${{ secrets.WECHAT_WORK_BOT_WEBHOOK }}", { | |
headers: { | |
"content-type": "application/json" | |
}, | |
data: { | |
chatid: "${{ secrets.WECHAT_WORK_CHAT_ID }}", | |
visible_to_user: userid, | |
msgtype: "markdown", | |
markdown: { | |
content: format(process.env.MESSAGE, (${{ github.event.pull_request.changed_files }}).toLocaleString(), (${{ github.event.pull_request.additions }}).toLocaleString(), (${{ github.event.pull_request.deletions }}).toLocaleString()), | |
attachments: [{ | |
callback_id: "review", | |
actions: [{ | |
name: "review_btn", | |
text: "Mark as Reviewed", | |
type: "button", | |
value: "Mark as Reviewed", | |
replace_text: "Already reviewed", | |
border_color: "2c974b", | |
text_color: "2c974b" | |
}, { | |
name: "ignore_btn", | |
text: "Mark as Ignored", | |
type: "button", | |
value: "Mark as Ignored", | |
replace_text: "Already ignored", | |
border_color: "6e7781", | |
text_color: "6e7781" | |
}] | |
}] | |
} | |
} | |
}); | |
request_review_target: | |
if: github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success' | |
runs-on: ubuntu-latest | |
outputs: | |
action: ${{ steps.parse.outputs.action }} | |
review_state: ${{ steps.parse.outputs.review_state }} | |
pull_request_number: ${{ steps.parse.outputs.pull_request_number }} | |
sender: ${{ steps.parse.outputs.sender }} | |
raw: ${{ steps.parse.outputs.raw }} | |
steps: | |
- name: Pull | |
uses: actions/github-script@v6.3.3 | |
with: | |
script: | | |
const { workflow_run } = context.payload; | |
const { actions } = github.rest; | |
const fs = require('fs'); | |
const { data: { artifacts } } = await actions.listWorkflowRunArtifacts({ | |
run_id: workflow_run.id, | |
...context.repo | |
}); | |
const [ artifact ] = artifacts.filter((artifact) => { | |
return artifact.name == "review_info" | |
}); | |
if (!artifact) { | |
throw new Error(`Missing review_info artifact generated in parent workflow(${workflow_run.id})`); | |
} | |
const download = await actions.downloadArtifact({ | |
artifact_id: artifact.id, | |
archive_format: 'zip', | |
...context.repo | |
}); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/review_info.zip`, Buffer.from(download.data)); | |
- name: Parse | |
id: parse | |
shell: python | |
run: | | |
import zipfile | |
import json | |
import os | |
with zipfile.ZipFile("review_info.zip", "r") as zip_ref: | |
buf = zip_ref.read("review_info") | |
review_info = json.loads(buf) | |
with open(os.getenv("GITHUB_OUTPUT"), 'w', encoding='utf-8') as file: | |
file.write("action=%s\n" % review_info["action"]) | |
file.write("review_state=%s\n" % review_info["review"]["state"]) | |
file.write("pull_request_number=%s\n" % review_info["pull_request"]["number"]) | |
file.write("sender=%s\n" % review_info["sender"]["login"]) | |
file.write("raw=%s\n" % json.dumps(review_info)) | |
changes_requested_comment: | |
needs: request_review_target | |
if: needs.request_review_target.outputs.action == 'submitted' && needs.request_review_target.outputs.review_state == 'changes_requested' | |
runs-on: ubuntu-latest | |
env: | |
MESSAGE: | | |
Hi, @${{ needs.request_review_target.outputs.sender }}. | |
I noticed that our reviewers requested changes to this pull request. | |
When you're done, **click the `Re-request review` button in the right sidebar(shown below)** to notify the reviewer. | |
 | |
steps: | |
- name: Token | |
uses: navikt/github-app-token-generator@v1 | |
id: get-token | |
with: | |
private-key: ${{ secrets.PRIVATE_KEY }} | |
app-id: ${{ secrets.APP_ID }} | |
- name: Find | |
uses: peter-evans/find-comment@v2.1.0 | |
id: find | |
with: | |
issue-number: ${{ needs.request_review_target.outputs.pull_request_number }} | |
body-includes: ${{ env.MESSAGE }} | |
- name: Comment | |
if: steps.find.outputs.comment-id == '' | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ needs.request_review_target.outputs.pull_request_number }} | |
reactions: eyes | |
body: ${{ env.MESSAGE }} |