Using github-script in a composite action to add a comment to an issue
In this recipe, we will use an action called github-script to leverage the power of the toolkit inside a composite action.
How to do it…
- Remove the run step with the bash script from the
action.ymlfile and replace it with agithub-scriptaction:- name: Awesome github script action uses: actions/github-script@v6 with: script: |
- Use the toolkit to read the input parameter, write a greeting to the log, and set the output parameter. This should be familiar from the Creating a TypeScript action recipe:
var whoToGreet = core.getInput('who-to-greet') core.notice(`Hello ${whoToGreet}`) core.setOutput('answer', 42) - Now, we want to add some additional functionality. If the workflow was triggered by an
issuesevent, then we want to add a comment to that issue. Check that the event that triggered the workflow was in factissuesand that...