github-script | Write workflows scripting the GitHub API in JavaScript | Continous Integration library
kandi X-RAY | github-script Summary
kandi X-RAY | github-script Summary
This action makes it easy to quickly write a script in your workflow that uses the GitHub API and the workflow run context.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of github-script
github-script Key Features
github-script Examples and Code Snippets
Community Discussions
Trending Discussions on github-script
QUESTION
I am following hashicopr learning guide on how to set up GitHub Actions and terraform. All is running great besides the step to update the PR with the Terraform Plan.
I am hitting the following error:
...ANSWER
Answered 2022-Mar-07 at 03:05I also encountered a similar issue.
I seem github-script
can't give to argument for too long script.
reference:
- https://github.com/robburger/terraform-pr-commenter/issues/6#issuecomment-826966670
- https://github.community/t/maximum-length-for-the-comment-body-in-issues-and-pr/148867
my answer:
QUESTION
I have been trying to understand how to get a multi-line comment written to a PR using github actions. I was trying to use github.rest.issues.createComment() as shown in Commenting a pull request... and then handling the multi-line issue by using an environmement variable as shown here: workflow commands. Ultimate goal is to take some multi-line output stdout from a python script (or a log file) and place that as a comment back to the PR that the workflow is running on. The yml file below runs fine up until the last step where I try to access the environment variable I created and use it as the body of the createComment(). The environment variable is created and appears to be available but fails when I try to use it for the body of the comment. Error from github actions is below the code. If I add quotes like body: "${{env.SCRIPT_OUTPUT}}"
then I get same error. I would like to use createComment() if possible, I know there is a create comment from Peter Evans that I will likely try next but trying to understand why this is not working.
ANSWER
Answered 2022-Jan-10 at 15:56The suggestion from @riqq to use back tics solved the issue. So just had to change body: ${{env.SCRIPT_OUTPUT}}
to:
QUESTION
This is what I am trying:
...ANSWER
Answered 2021-Dec-09 at 08:01You don't need the refs/
prefix in that API. Looking at the docs, it says that:
Returns a single reference from your Git database. The :ref in the URL must be formatted as heads/ for branches and tags/ for tags.
So if you change your step to the below, it should work.
QUESTION
I need to create a YAML job that checks if a milestone is set on a PR and fail an automated check if there is no milestone set.
This is the job that I have in the .yml file:
...ANSWER
Answered 2021-Oct-05 at 03:43You can use a Github API call in github-script action using github.request
like this:
QUESTION
I have a project with Github Actions that implements multiple workflows that can be triggered by a single push event (depending on path filter).
So a push with a single commit can trigger multiple workflows, so far so good.
In each workflow I am running actions/github-script
to create dynamic run-checks with the following step:
ANSWER
Answered 2021-Sep-14 at 17:54Try setting Custom Script
to something different for each check run you create. I think multiple check runs with the same names are collapsed into only showing the last one. The reason is that that way you can override an status on a commit, by using the same name.
QUESTION
Let's take this example composite action found on Github's documentation:
...ANSWER
Answered 2021-Apr-27 at 13:42It seems my attempt was correct with the exception of one detail:
Instead of:
QUESTION
Let's take as an example this workflow with two jobs - build and comment:
...ANSWER
Answered 2021-Apr-23 at 16:57You can use the if
conditional (reference) to prevent a job or a step from running unless a condition is met.
For example, here, you could add if: ${{ github.event_name == 'pull_request' }}
to the comment job
to execute it only if the event that triggered the workflow is a pull_request
.
QUESTION
I am trying to build a GitHub workflow that performs simple pre-commit checks whenever a PR is created into a certain repository and triggers a message if some check has failed. The problem is that I want that message to be as specific as possible and, therefore, the message has to contain the error that is preventing the check to succeed. To perform the pre-commit check I am using pre-commit action and, to automate the messages, I am using the official actions github-script.
Since I am utilizing the pre-commit action to perform the checks, I think I am not able to use the set-output solution to define the outputs of the step that is validating for the errors and reference those outputs later in my error message. Is there any other way to workaround this problem?
Here is an excerpt of my workflow pipeline:
...ANSWER
Answered 2021-Feb-25 at 07:46It is not possible using the provided action. Unless there is some kind of command line argument you can pass to pre-commit to write the error to a file and then pass it around. I went through the doc but didn't find any.
If you really need this, you will have to write your own action.
QUESTION
I have a step in a github workflow job that looks like this:
...ANSWER
Answered 2021-Jan-22 at 13:44Well, console.log(result.addComment.commentEdge.node.id)
does the trick.
QUESTION
I'm using github-script for GitHub actions, which allows you to easily access GitHub API. I'm trying to check if an issue has not been closed by clicking on the "close button", that is, via a commit or via merging a pull request that includes a closing commit (or closes in the PR body). However, there does not seem an easy way to do that. This is the event information the GitHub API returns:
- If the issue has been closed from a commit, it adds the commit_id
- If the issue has been closed from GitHub app (this does not include the web, apparently),
performed_via_github_app
is set to non-null.
However, there does not seem to be a special way to signal an issue has been closed by a pull request, apparently. Or is it?
...ANSWER
Answered 2020-Oct-05 at 15:38Well, short answer is no, there's no way to do this and the GitHub API does not reveal either the PR it's been closed from or the fact that it's been closed from a PR as opposed to a commit.
So we'll have to settle for second-best. Often the issue is connected
to the PR in the previous event. Unless it's an open PR and you've already merged a commit that mentions the issue, you'll have a connected
and closed
event the one after the other. So you can use this (or similar) to check for PRs:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install github-script
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page