mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-30 23:40:07 +00:00
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Fleny <Fleny113@outlook.com>
115 lines
4.2 KiB
YAML
115 lines
4.2 KiB
YAML
name: Comment Benchmark Result
|
|
permissions:
|
|
contents: read
|
|
actions: read
|
|
pull-requests: write
|
|
on:
|
|
workflow_run:
|
|
workflows: [Benchmark with retry]
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
comment-benchmark-result:
|
|
name: Comment Benchmark Result
|
|
runs-on: ubuntu-latest
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: denoland/setup-deno@main
|
|
with:
|
|
deno-version: v1.x
|
|
- name: Download Commit Data Artifact
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
});
|
|
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
|
|
return artifact.name == "commitData"
|
|
})[0];
|
|
let download = await github.rest.actions.downloadArtifact({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
artifact_id: matchArtifact.id,
|
|
archive_format: 'zip',
|
|
});
|
|
let fs = require('fs');
|
|
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/commitData.zip`, Buffer.from(download.data));
|
|
|
|
- name: Unzip Commit Data Artifact
|
|
run: unzip commitData.zip
|
|
|
|
- name: Download Result Artifact
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
});
|
|
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
|
|
return artifact.name == "benchmarkResults"
|
|
})[0];
|
|
let download = await github.rest.actions.downloadArtifact({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
artifact_id: matchArtifact.id,
|
|
archive_format: 'zip',
|
|
});
|
|
let fs = require('fs');
|
|
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/benchmarkResults.zip`, Buffer.from(download.data));
|
|
|
|
- name: Unzip Result Artifact
|
|
run: unzip benchmarkResults.zip
|
|
|
|
- name: Generate Message
|
|
id: genMessage
|
|
run: |
|
|
MESSAGE=$(deno run -A scripts/generateMessage.js)
|
|
echo "MESSAGE<<EOF" >> $GITHUB_ENV
|
|
echo "$MESSAGE" >> $GITHUB_ENV
|
|
echo "EOF" >> $GITHUB_ENV
|
|
|
|
- name: 'Comment on PR'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const fs = require('fs');
|
|
const commit_sha = fs.readFileSync('./sha', 'utf-8');
|
|
const repo = fs.readFileSync('./repo', 'utf-8');
|
|
if (repo.split('/')[1] === undefined) process.exit(0)
|
|
const pr = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
|
commit_sha: commit_sha.slice(0,-1),
|
|
owner: repo.split('/')[0],
|
|
repo: repo.split('/')[1].slice(0,-1),
|
|
});
|
|
if (pr.data[0]) {
|
|
const comments = await github.rest.issues.listComments({
|
|
owner: "discordeno",
|
|
repo: "discordeno",
|
|
issue_number: pr.data[0].number,
|
|
})
|
|
const oldComment = comments.data.find((comment) => comment.body.includes('benchmark comment by ci'))
|
|
if(!oldComment) {
|
|
github.rest.issues.createComment({
|
|
issue_number: pr.data[0].number,
|
|
owner: "discordeno",
|
|
repo: "discordeno",
|
|
body: `${{ env.MESSAGE }}`
|
|
})
|
|
} else {
|
|
github.rest.issues.updateComment({
|
|
owner: "discordeno",
|
|
repo: "discordeno",
|
|
comment_id: oldComment.id,
|
|
body: `${{ env.MESSAGE }}`
|
|
});
|
|
}
|
|
}
|