Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Comment Pull Request #43

Comment Pull Request

Comment Pull Request #43

Workflow file for this run

name: Comment Pull Request
on:
workflow_run:
workflows: ["Pull Request"]
types: [completed]
permissions:
pull-requests: write
jobs:
comment-pr:
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id}},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "process";
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/process.zip', Buffer.from(download.data));
- name: Unzip artifact
run: unzip process.zip
- name: Comment on PR
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var fs = require('fs');
var issueNumber = Number(fs.readFileSync('pr.txt'));
var message = fs.readFileSync('message.txt').toString();
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: message
});