Skip to content

feat: output pr_comments to github action #412

feat: output pr_comments to github action

feat: output pr_comments to github action #412

Workflow file for this run

name: Commit Check
on:
pull_request:
branches: [ 'main' ]
workflow_dispatch:
jobs:
commit-check:
runs-on: ubuntu-latest
permissions: # use permissions because of use pr-comments
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }} # checkout PR HEAD commit
fetch-depth: 0 # fetch all history for all branches and tags
- uses: ./ # self test
id: commit-check
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # use GITHUB_TOKEN because of use pr-comments
with:
message: true
branch: true
author-name: true
author-email: true
commit-signoff: true
merge-base: true
imperative: true
job-summary: true
pr-comments: ${{ github.event_name == 'pull_request' }}
- name: Save PR comments to pr-comments.txt
run: echo "${{ steps.commit-check.outputs.pr_comments }}" > pr-comments.txt
- name: Post PR comments
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const content = fs.readFileSync('pr-comments.txt', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: content
});