According to Github scripts docs, I can post to a Github issue like,
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👋 Thanks for reporting!'
})
I want to post a body that reads data from a file. I tried,
body: fs.readFileSync('/my/cool/file')
but it complains that fs
does not exist.
How do I do this?
Install the fs
module and use require('fs')
before using the fs
module.
require
A proxy wrapper around the normal Node.jsrequire
to enable requiring relative paths (relative to the current working directory) and requiring npm packages installed in the current working directory
source
jobs:
comment:
runs-on: ubuntu-latest
steps:
- run: npm install fs
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs')
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: fs.readFileSync('/my/cool/file', 'utf8')
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With