Bugfix/turbo mem leak #4800
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 request checks approval' | |
on: | |
pull_request_target: | |
branches: | |
- master | |
- main | |
env: | |
greetings_message: | | |
👋 Thanks for your contributing! | |
Our collaborators will review your pull request after all status checks have been passed. | |
safety_changes_message: | | |
After a quick scan, I have approved%sworkflow%s to run. | |
risky_changes_message: | | |
Sorry, due to risky changes, I can\'t approve%sworkflow%s to run. | |
Don\'t worry about it, our collaborators will handle it asap. | |
jobs: | |
pull_request_checks_approval: | |
if: github.repository == 'Tencent/Hippy' | |
permissions: | |
actions: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Greetings | |
if: github.event.action == 'opened' | |
uses: actions/[email protected] | |
with: | |
script: | | |
const { owner, repo } = context.repo; | |
const { pull_request } = context.payload; | |
const { issues } = github.rest; | |
await issues.createComment({ | |
owner, | |
repo, | |
issue_number: pull_request.number, | |
body: process.env['greetings_message'], | |
}); | |
- name: Token | |
uses: navikt/github-app-token-generator@v1 | |
id: get-token | |
with: | |
private-key: ${{ secrets.BOT_APP_KEY }} | |
app-id: ${{ secrets.BOT_APP_ID }} | |
- name: Checks | |
uses: actions/[email protected] | |
with: | |
github-token: ${{ steps.get-token.outputs.token }} | |
script: | | |
const { owner, repo } = context.repo; | |
const { pull_request } = context.payload; | |
const { actions, pulls, issues } = github.rest; | |
const util = require('util'); | |
const per_page = 100; | |
let workflow_runs = (await github.paginate(actions.listWorkflowRunsForRepo, { | |
owner, | |
repo, | |
per_page, | |
event: 'pull_request', | |
status: 'action_required' | |
})).filter(workflow_run => workflow_run.head_sha === pull_request.head.sha); | |
if (workflow_runs.length === 0) { | |
return; | |
} | |
const [includeRiskFiles] = await github.paginate(pulls.listFiles, { | |
owner, | |
repo, | |
per_page, | |
pull_number: pull_request.number | |
}, ({ data: files }, done) => { | |
if (files.some(file => file.filename.startsWith('.github/workflows'))) { | |
done(); | |
return [true]; | |
} | |
return []; | |
}); | |
if (!includeRiskFiles) { | |
await Promise.all(workflow_runs.map(workflow_run => actions.approveWorkflowRun({ | |
owner, | |
repo, | |
run_id: workflow_run.id, | |
}))); | |
} | |
await issues.createComment({ | |
owner, | |
repo, | |
issue_number: pull_request.number, | |
body: util.format(process.env[includeRiskFiles ? 'risky_changes_message' : 'safety_changes_message'], workflow_runs.length === 1 ? " the " : " ", workflow_runs.length > 1 ? "s" : ""), | |
}); |