Giter Club home page Giter Club logo

add-pr-comment's Introduction

add-pr-comment

All Contributors

A GitHub Action which adds a comment to a pull request's issue.

This actions also works on issue, issue_comment, deployment_status, push and any other event where an issue can be found directly on the payload or via a commit sha.

Features

  • Modify issues for PRs merged to main.
  • By default will post "sticky" comments. If on a subsequent run the message text changes the original comment will be updated.
  • Multiple sticky comments allowed by setting unique message-ids.
  • Optional message overrides based on job status.
  • Multiple posts to the same conversation optionally allowable.
  • Supports a proxy for fork-based PRs. See below.
  • Supports creating a message from a file path.

Usage

Note that write access needs to be granted for the pull-requests scope.

on:
  pull_request:

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        with:
          message: |
            **Hello**
            ๐ŸŒ
            !

You can even use it on PR Issues that are related to PRs that were merged into main, for example:

on:
  push:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        with:
          message: |
            **Hello MAIN**

Configuration options

Input Location Description Required Default
message with The message you'd like displayed, supports Markdown and all valid Unicode characters. maybe
message-path with Path to a message you'd like displayed. Will be read and displayed just like a normal message. Supports multi-line input and globs. Multiple messages will be concatenated. maybe
message-success with A message override, printed in case of success. no
message-failure with A message override, printed in case of failure. no
message-cancelled with A message override, printed in case of cancelled. no
message-skipped with A message override, printed in case of skipped. no
status with Required if you want to use message status overrides. no {{ job.status }}
repo-owner with Owner of the repo. no {{ github.repository_owner }}
repo-name with Name of the repo. no {{ github.event.repository.name }}
repo-token with Valid GitHub token, either the temporary token GitHub provides or a personal access token. no {{ github.token }}
message-id with Message id to use when searching existing comments. If found, updates the existing (sticky comment). no
refresh-message-position with Should the sticky message be the last one in the PR's feed. no false
allow-repeats with Boolean flag to allow identical messages to be posted each time this action is run. no false
proxy-url with String for your proxy service URL if you'd like this to work with fork-based PRs. no
issue with Optional issue number override. no
update-only with Only update the comment if it already exists. no false
GITHUB_TOKEN env Valid GitHub token, can alternatively be defined in the env. no
preformatted with Treat message text as pre-formatted and place it in a codeblock no
find with Patterns to find in an existing message and replace with either replace text or a resolved message. See Find-and-Replace for more detail. no
replace with Strings to replace a found pattern with. Each new line is a new replacement, or if you only have one pattern, you can replace with a multiline string. no

Advanced Uses

Proxy for Fork-based PRs

GitHub limits GITHUB_TOKEN and other API access token permissions when creating a PR from a fork. This precludes adding comments when your PRs are coming from forks, which is the norm for open source projects. To work around this situation I've created a simple companion app you can deploy to Cloud Run or another host to proxy the create comment requests with a personal access token you provide.

See this issue: https://github.community/t/github-actions-are-severely-limited-on-prs/18179/4 for more details.

Check out the proxy service here: https://github.com/mshick/add-pr-comment-proxy

Example

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        with:
          message: |
            **Howdie!**
          proxy-url: https://add-pr-comment-proxy-94idvmwyie-uc.a.run.app

Status Message Overrides

You can override your messages based on your job status. This can be helpful if you don't anticipate having the data required to create a helpful message in case of failure, but you still want a message to be sent to the PR comment.

Example

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          message: |
            **Howdie!**
          message-failure: |
            Uh oh!

Multiple Message Files

Instead of directly setting the message you can also load a file with the text of your message using message-path. message-path supports loading multiple files and files on multiple lines, the contents of which will be concatenated.

Example

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          message-path: |
            message-part-*.txt

Find-and-Replace

Patterns can be matched and replaced to update comments. This could be useful for some situations, for instance, updating a checklist comment.

Find is a regular expression passed to the RegExp() constructor. You can also include modifiers to override the default gi.

Example

Original message:

[ ] Hello
[ ] World

Action:

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          find: |
            \n\\[ \\]
          replace: |
            [X]

Final message:

[X] Hello
[X] World

Multiple find and replaces can be used:

Example

Original message:

hello world!

Action:

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          find: |
            hello
            world
          replace: |
            goodnight
            moon

Final message:

goodnight moon!

It defaults to your resolved message (either from message or message-path) to do a replacement:

Example

Original message:

hello

<< FILE_CONTENTS >>

world

Action:

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        if: always()
        with:
          message-path: |
            message.txt
          find: |
            << FILE_CONTENTS >>

Final message:

hello

secret message from message.txt

world

Bring your own issues

You can set an issue id explicitly. Helpful for cases where you want to post to an issue but for some reason the event would not allow the id to be determined.

Example

In this case add-pr-comment should have no problem finding the issue number on its own, but for demonstration purposes.

on:
  deployment_status:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - id: pr
        run: |
          issue=$(gh pr list --search "${{ github.sha }}" --state open --json number --jq ".[0].number")
          echo "issue=$issue" >>$GITHUB_OUTPUT
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - uses: mshick/add-pr-comment@v2
        with:
          issue: ${{ steps.pr.outputs.issue }}
          message: |
            **Howdie!**

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

ReenigneArcher
ReenigneArcher

๐Ÿ’ป
Aryella Lacerda
Aryella Lacerda

๐Ÿ’ป
vincent-joignie-dd
vincent-joignie-dd

๐Ÿ’ป
Akhan Zhakiyanov
Akhan Zhakiyanov

๐Ÿ’ป
Alex Hatzenbuhler
Alex Hatzenbuhler

๐Ÿ’ป
Tommy Wang
Tommy Wang

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

add-pr-comment's People

Contributors

ahatzz11 avatar alekseyleshko avatar allcontributors[bot] avatar aryella-lacerda avatar dependabot[bot] avatar jritsema avatar juliangro avatar mshick avatar ostrowr avatar reenignearcher avatar vincent-joignie-dd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

add-pr-comment's Issues

Update instead of duplicate

Hey, nice github action!

I'm using it to write which packages in a monorepo have been affected.

Is it possible to always edit the same message? without writing a new one. I see right now you compare the text, but I'd like to always update the existing message if exists.

In my use case for example, you could run into this confusion:

commit-1 changes package A
commit-2 changes package A, package B
commit-3 changes package A (reverts the package B change)

In the current flow, we won't print a new comment because you already find the comment after commit-1

I can make a PR + new config

v2 major tag didn't get updated for v2.4.0

Hey @mshick! I appreciate the PR merge of #92 and the quick release of v2.4.0! This issue is to note that the v2 tag didn't seem to get an update. We reference action versions as major tags (like most actions recommend), and I'd love to get the latest release with this:

    - name: Add PR comment
      uses: mshick/add-pr-comment@v2

Thanks!

Force-fail the action

Sometimes I wan't to leave a comment on a PR if an action fails, then I use it like this:

            - name: Step that fails
              id: failed_step
              continue-on-error: true
              run: |
                  echo "this fails" \
                  exit 1

            - name: Post Plan Failure
              if: steps.failed_step.outcome == 'failure'
              uses: mshick/add-pr-comment@v2
              with:
                  repo-token: ${{ secrets.GITHUB_TOKEN }}
                  message: |
                       ```
                      ${{ steps.failed_step.outputs.stderr }}
                      ```

But then because the last action of the job was successful, the job status it's successful too.

It would be nice to have an argument 'force_fail' that if it's true... the action fails after putting the comment in the PR.

I already implemented it, but wasn't sure if I should make a PR or and Issue first.

This would be my first Open Source contribution!! ;P

[Question] Conditional message depends on steps

Do we have a way to write a condition message depending on the success of the steps on a job? I want to write a comment with: 'foo' if step1 succeeds, and 'bar' if step2 succeeds. Also, If both succeed it should appear 'foo' and 'bar'

Output the id

Thanks for the great work!

It would be great if it could output the created comment id

[Question] How could one use string interpolation inside of the message?

Hello,

I would like to use string interpolation in the message and I'm trying but cannot figure it out. Is it even possible?

Here is my example:

    steps:
      - name: Set ticket number
        run: echo "TICKET_NUMBER=$(echo $GITHUB_REF_NAME_SLUG | cut -c1-9 | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
      - uses: mshick/add-pr-comment@v1
        with:
          message: 'Link to JIRA ticket: https://jira.jira/jira/browse/$TICKET_NUMBER'
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          repo-token-user-login: 'github-actions[bot]'

The output is Link to JIRA ticket: https://jira.jira/jira/browse/$TICKET_NUMBER. If I do something like 'Link to JIRA ticket: https://jira.jira/jira/browse/${{ github.head_ref }}' just to test it out the output is https://jira.jira/jira/browse/

Feature Request: Cleanup Previous comments

What are your thoughts on having the ability to clean up old comments? The problem would be that there are situations where multiple comments are made in the same workflow, as in matrix jobs, so we would need some sort of identifier, but I think we can achieve this through embedding this identifier within a comment <!-- insert_identifier_here --> within the comment it self. This would be a argument that the user needs to supply and it is their responsibility to ensure it is consistent and repeatable across action runs.

I can take a shot at it, but was just curious on your thoughts on it.

node12 is deprecated. Upgrade to node16

Hello

Github has begun displaying warnings when this action is being used because node12 is being deprecated for github actions. Can you please upgrade the node js version to 16? Thank you

Luke

Leading Whitespace is Trimmed

Hello,

I'm using the add-pr-comment Github action to output lint fix results into my PRs comments. For example, a SQL after linting may look like the following:

SELECT
    FIRST_NAME,
    LAST_NAME,
    DEPARTMENT_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 90;

In my workflow I output the above into an intermediate file results and pass this results file to the messagePath for my add-pr-comment step.

However the comment comes out as:

SELECT
FIRST_NAME,
LAST_NAME,
DEPARTMENT_ID
FROM EMPLOYEES
WHERE DEPARTMENT_ID = 90;

Which doesn't accurately reflect the results.

[Feature] Allow `message-path` fallback if file not found

Hey there - thank you for this excellent Action!

I would like to ask for a fallback mechanism, where if the message-path file is missing, the contents of some configured key is used instead. Not /necessarily/ message-failure (as I can see the disadvantages of overloading its purpose), however using that field would seem to communicate the /intent/ here.

Rationale

I find myself most often configuring this Action via the message-path param; primarily for longer-form "result of the build/workflow" formatted comments.

However, when a build comprising several steps /fails/, in ways apart from "a test run completed, but with failures", 2 things happen:

  1. I'm almost always left wanting to communicate this structural failure in some shorter-but-still-formatted message
  2. The message-path file hasn't been created, due to the build/etc failure... failing!

Right now, to use this Action to cope with this situation, I need to arrange for a shell command step to run ahead of this Action, every time, to check if the message-path file exists; and, if it doesn't, dump my generic, short, formatted"Build failed" message in the file.

Then this Action can be activated unconditionally, with a definitely-existing file.

I /suspect/ I'm not alone in this flow, where I don't have a nice step.<foo>.conclusion way to identify, and communicate to the Action, that "the build failed". Where instead it's simply the fact that the file is missing which is the indicator of failure -- and I'm currently having to script around that scenario pretty frequently.

I would like to request that this Action remove that burden from me, the consumer, by "simply" adding a fallback, in cases where the message-path file is missing. โค๏ธ

Support pre-formatted text for `message-path`

I'm currently using add-pr-comment for commenting out a report that is generated by my repo. The report is a table and the output of a console which must retain its formatting.

I suggest adding the following options:

  • Allow appending multiple messages to each other, that way I could add backticks within the configuration
  • Adding in an option for code blocks: code-block: true

status: ${{ job.status }} is missing in the example in README.md

The doc in main is not updated and still shows the old example for status:

on:
  pull_request:

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        with:
          if: always()
          message: |
            **Howdie!**
          message-failure: |
            Uh oh!

Eventhough you merged an updated example in https://github.com/mshick/add-pr-comment/pull/62/files

jobs:
  pr:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: mshick/add-pr-comment@v2
        with:
          if: always()
          message: |
            **Howdie!**
          message-failure: |
            Uh oh!
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          status: ${{ job.status }}

Not sure what went wrong.

Encoding pipes?

I have a workflow using this that prints a table which includes pipe characters.

The workflow part is:

- name: Comment PR
  uses: mshick/add-pr-comment@v2
  with:
    message-id: 'node-dependencies-count'
    message: |
      **๐Ÿ‘จโ€๐Ÿ’ป PR Branch Node Dependencies Count:**
      ```
      ${{ env.COUNT }}
      ```
    repo-token: '${{ github.token }}'

When I try to run this I get the error:

 Error: Unable to process file command 'env' successfully.
Error: Invalid format '| Package                          | Dependency Count |'

Is there some way to prevent this by correctly encoding the pipe signs?

Could ```message``` and ```message-path``` be combined

I got a question about the composition of the message. Could we combine usage of message and message-path to form a new message. Like, a template is posed in message and then some dynamic message is posed in the file. By doing so, we could generate more complex message as comment.

Argument list is too long

We are not able to Commnet the PR for more than 262,144 characteristics. We are getting a Argument list is too long error. Requesting you to please let us know if we can increase the limit of the PR characteristics

error: body is too long (maximum is 65536 characters)

Problem

If pr comments are long, github API throws body is too long (maximum is 65536 characters) error

Error: Validation Failed: {"resource":"IssueComment","code":"unprocessable","field":"data","message":"Body is too long (maximum is 65536 characters)"}

Reproducible example file below, note that i am using the newly added message-path parameter to send the PR comment as a file.

name: PR comment test

on:
  push:
  workflow_call:

jobs:
  pr_comment_test:
    name: pr_command_help
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - name: comment message
        run: |
          wget --quiet https://github.com/kishaningithub/randomtext/releases/download/v1.2.1/randomtext_1.2.1_linux_amd64.deb
          sudo dpkg -i randomtext_1.2.1_linux_amd64.deb
          
          echo "Available commands (300 KB)" > pr-comment.txt
          randomtext -size 300KB -type words >> pr-comment.txt

          du -sh pr-comment.txt

      - name: Post apply output to GitHub PR
        uses: mshick/add-pr-comment@v2
        with:
          allow-repeats: true
          message-path: "pr-comment.txt"

Run Link: https://github.com/kishaningithub/github-actions-expermiments/actions/runs/4860867805/jobs/8665212807?pr=1

workflow file: https://github.com/kishaningithub/github-actions-expermiments/actions/runs/4860867805/workflow?pr=1

Use case

  • I am using this action to post output of terraform plan as a PR comment, this can get pretty long depending on the number of resources being affected

Add `update-only` configuration option to prevent initial creation of a comment in certain cases

Hello!

I have a workflow where we have two actions that update the same comment. The first action posts a message saying a deployment was complete, and the second action posts a message saying the deployment was deleted. There's a case though where the deployment doesn't happen (e.g. only a README was changed and no deployment was created), but the 'deployment deleted' comment still gets made which is a bit misleading.

Is there an option to say 'only update a comment that already exists' instead of creating one? I looked through the docs and nothing immediately jumped out at me so I thought I'd start an issue to discuss it.

Thanks in advance!

GitHub Actions - set-output command is deprecated

Hey Team,

I was working with one of my GH workflow and found the below warning.

Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

Can we update action accordingly?

comment on a PR in another repo

Is it possible to comment on a PR in another repo?

I have a somewhat complicated workflow. The workflow in one repo will trigger a workflow in another repo with a repository dispatch event. I want the triggered workflow to comment on the PR from the repo that triggered the repository dispatch event.

Any ideas?

Can the node version upgrade be part of v3?

Context

  • We have failing pipelines due to 2.8.2 minor version which upgrades the node runtime from 16 to 20. Since we are running this in a self hosted runner running amzon linux 2 which out of the box comes with an ancient GLIBC version and is not supported from node js versions >= 18

Error

/home/runner-7748545357-818749055714-0/action-runner/externals/node20/bin/node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /home/runner-7748545357-818749055714-0/action-runner/externals/node20/bin/node)
/home/runner-7748545357-818749055714-0/action-runner/externals/node20/bin/node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /home/runner-7748545357-818749055714-0/action-runner/externals/node20/bin/node)

Our pipeline

  - name: Post Comment to GitHub PR
    uses: mshick/add-pr-comment@v2
    with:
      message-path: "long-message.txt"

Proposal

Comments with references to other PRs

Not sure if this is an issue with add-pr-comment or something else. I'm posting a comment that contains a reference to a PR in another repo. The comment is correctly posted but, in the PR in the other repo, I don't see a reference like you would normally get if you did this manually. I manually tried posting a comment with the same text, and it does appear a reference in the other PR.

Is this something that we need to configure through the action or the token?

How to handle multiple PR's?

Hi Team,

I have doubt on how this works for multiple PR's? Suppose if I opened 4 PR's in my GitHub repo, in which PR the required message will be posted as a comment? Whether its latest PR or PR which is raised first?
Is it possible to mention PR number in the workflow so that I can post my comments in specific PR ?

Comment on a git commit

I'm building a deploy preview commenting step and initially I didn't add if: github.event_name != 'push' to my comment steps so my comments were getting updated with the main branch deploy links. Adding the if statement works for that, but I realize I'd like to comment on the commit to main w/ the deploy status.

I realize that's not something this action explicitly supports, but it'd be useful. I wonder if I should explore how to do action status links like Netlify and other apps do instead??

Removing a comment

I run this as part of a CI pipeline and add a PR comment if there is a failure. I would like to remove the PR comment entirely if the steps succeed.

Maybe an attribute remove: true or similar.

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

This issue is similar to #93, except that it throws a JS error.

I am also using this action to post the output of a terraform plan as a PR comment using a txt file.

[3148:0x4bfddd0]     5515 ms: Mark-sweep (reduce) 1992.5 (2058.2) -> 1992.2 (2059.2) MB, 16.7 / 0.0 ms  (average mu = 0.958, current mu = 0.285) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb0a860 node::Abort() [/home/runner/runners/2.305.0/externals/node16/bin/node]
 2: 0xa1c193 node::FatalError(char const*, char const*) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 3: 0xcf9a6e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 4: 0xcf9de7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 5: 0xeb1685  [/home/runner/runners/2.305.0/externals/node16/bin/node]
 6: 0xec134d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 7: 0xec404e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 8: 0xe852c2 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/home/runner/runners/2.305.0/externals/node16/bin/node]
 9: 0xe7d8d4 v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawWithImmortalMap(int, v8::internal::AllocationType, v8::internal::Map, v8::internal::AllocationAlignment) [/home/runner/runners/2.305.0/externals/node16/bin/node]
10: 0xe7f931 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [/home/runner/runners/2.305.0/externals/node16/bin/node]
11: 0x125af3c v8::internal::IncrementalStringBuilder::Extend() [/home/runner/runners/2.305.0/externals/node16/bin/node]
12: 0xfa9dbd v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [/home/runner/runners/2.305.0/externals/node16/bin/node]
13: 0xfa93e9 v8::internal::JsonStringifier::SerializeString(v8::internal::Handle<v8::internal::String>) [/home/runner/runners/2.305.0/externals/node16/bin/node]
14: 0xfabc31 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/home/runner/runners/2.305.0/externals/node16/bin/node]
15: 0xfaf691 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/home/runner/runners/2.305.0/externals/node16/bin/node]
16: 0xfb0faf v8::internal::JsonStringify(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/home/runner/runners/2.305.0/externals/node16/bin/node]
17: 0xd7bc97 v8::internal::Builtin_JsonStringify(int, unsigned long*, v8::internal::Isolate*) [/home/runner/runners/2.305.0/externals/node16/bin/node]
18: 0x15f2e19  [/home/runner/runners/2.305.0/externals/node16/bin/node]

Is there any way to address this?

Undesired performance with ```update-only``` setting at first run

I had a workflow which will check a summary file after tests.
The logs are as follows:

Run mshick/add-pr-comment@v2
  with:
    update-only: true
    preformatted: true
    message-path: benchmark/summary.txt
......
  env:
    ARTIFACTS_PATH: ~/.julia/artifacts
    PACKAGES_PATH: ~/.julia/packages
    REGISTRIES_PATH: ~/.julia/registries
    PRECOMPILATION_CACHE_PATH: 
    JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
no existing comment found and update-only is true, exiting

I desire that at the first run of this workflow, if the summary file exists, then a comment should be created to notify me and then in later runs, the comments should be updated if the condition still holds. But it seems that update-only setting could not statisfy both.

Add env in message

Are there any why to use env in comments like

       -  name: Commenting environment link in PR
          uses: mshick/add-pr-comment@v1
          with:
            repo-token: ${{ secrets.GITHUB_TOKEN }}
            message: |
              You can see your code in this [environment](https://mylink-$PR_NUMBER.herokuapp.com) ๐Ÿš€

Is it possible to print an env value with multiple lines?

Here is my setup:

- name: Comment if PR
        uses: mshick/add-pr-comment@v1
        with:
          dummy-var: "hello world"
          message: |
            ## ๐Ÿค– Letsbuilders dependencies list ๐Ÿค–
            Take a look at the Letsbuilders dependencies list bellow and make sure it is correct and does not contain multiple versions of the package or and also that each package is only listed once ๐Ÿ•ต๏ธ
            ```
            "${{ env.LB_DEPS }}"
            ```

          repo-token: ${{ secrets.GITHUB_TOKEN }}
          allow-repeats: true

env.LB_DEPS is basically the result of grep which is run in the previous step. I'l like to display it in the comment but for some reason CRLF are not kept thus the result is displayed in one line.

Is there something I should be doing to fix that?

Thanks!

Error: Resource not accessible by integration

Hey, sorry to pick on you but I've been trying a whole bunch of commenting actions. Not one has worked. I am getting the following error and cannot get to the bottom of it:

https://github.com/mattcanty/dns/runs/5058217662?check_suite_focus=true#step:3:8

0s
Run mshick/add-pr-comment@v[1](https://github.com/mattcanty/dns/runs/5058217662?check_suite_focus=true#step:3:1)
  with:
    message: **Hello MASTER**
  
    allow-repeats: true
  env:
    GITHUB_TOKEN: ***
Error: Resource not accessible by integration

I end up on this page a lot, but it's not really telling me anything:
https://dev.to/callmekatootie/debug-resource-not-accessible-by-integration-error-when-working-with-githubs-graphql-endpoint-5bim

Am I meant to have a GitHub App set up for this to work?

[PSA] No need for proxy for fork based PRs!

Hi, I am not sure if this is a feature that was newly introduced in Github actions, but it is completely unnecessary to use a proxy based solution for PRs from forks.

All you need to do is replace the trigger "pull_request" to "pull_request_target". This will allow the workflow to access secrets. More info here: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#pull_request_target and I quote:

This event is similar to pull_request, except that it runs in the context of the base repository of the pull request, rather than in the merge commit. This means that you can more safely make your secrets available to the workflows triggered by the pull request, because only workflows defined in the commit on the base repository are run. For example, this event allows you to create workflows that label and comment on pull requests, based on the contents of the event payload.

The only catch of this approach is that the workflow file used is the one already checked into the repo. So if you are creating a new workflow that uses secrets and want to test this in the PR that is checking in this file, it won't work because this file does not yet exist in the base repository. But once the PR is merged and the workflow file is in the base repo, subsequent PRs from forks will trigger the workflow properly.

This is a public service announcement of types so that others can use this and other actions that rely on secrets without using proxies and can still have them work for PRs from a fork!

File content as the message

I have the message prepared in the step and it is multyline. Unfortunately, github action output truncate multiline. I decided to write message to file, but it is not possible to print file right now.

Do you think it is good idea?

Cannot destructure property `number` of 'undefined' or 'null'

Using v1 in a workflow I am unable to add a comment to the PR using this action.

---
name: comment-test

on:
  push:
    branches: [master]

jobs:
  comment-test:
    runs-on: ubuntu-18.04
    steps:
      - name: add pr comment
        uses: mshick/add-pr-comment@v1
        with:
          message: |
            **Hello**
            ๐ŸŒ
            !
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          allow-repeats: false

Example raw logs output:

2020-03-10T13:57:06.4673964Z ##[section]Starting: Request a runner to run this job
2020-03-10T13:57:06.5654537Z Requesting a hosted runner in current repository's account/organization with labels: 'ubuntu-18.04', require runner match: True
2020-03-10T13:57:06.6736337Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-03-10T13:57:06.7043034Z ##[section]Finishing: Request a runner to run this job
2020-03-10T13:57:11.1145519Z Current runner version: '2.165.2'
2020-03-10T13:57:11.1148183Z Prepare workflow directory
2020-03-10T13:57:11.1376967Z Prepare all required actions
2020-03-10T13:57:11.1399954Z Download action repository 'mshick/add-pr-comment@v1'
2020-03-10T13:57:13.7863002Z ##[group]Run mshick/add-pr-comment@v1
2020-03-10T13:57:13.7864106Z with:
2020-03-10T13:57:13.7865070Z   message: **Hello**
รฐลธล’๏ฟฝ
!

2020-03-10T13:57:13.7866162Z   repo-token: ***
2020-03-10T13:57:13.7867258Z   allow-repeats: false
2020-03-10T13:57:13.7868150Z ##[endgroup]
2020-03-10T13:57:14.2404398Z ##[error]Cannot destructure property `number` of 'undefined' or 'null'.
2020-03-10T13:57:14.2648031Z Cleaning up orphan processes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.