mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-21 10:50:09 +00:00
* Do some code changes & run prettier and eslint
* Fix test:test-type script
* Apply code review suggestions
* update heartbeat interval & add a reason for the specific value
* Fix husky error
* Update to TS 5.5
And use ${configDir}
* Fix test.json tsconfig base
---------
Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
112 lines
4.1 KiB
YAML
112 lines
4.1 KiB
YAML
name: Comment Benchmark Result
|
|
|
|
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@v4
|
|
- 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 }}`
|
|
});
|
|
}
|
|
}
|