actions
actions copied to clipboard
Comment on PR does not work: UnhandledPromiseRejectionWarning
What happened?
Hi, I have a workflow to run the preview
on PRs which calls a reusable workflow to run jobs on multiple stacks.
Steps to reproduce
The caller
job calls callee
jobs which are responsible for each stack.
call-pulumi-preview-with-data:
name: ${{ matrix.service_name }}
strategy:
fail-fast: false
matrix:
include:
- service_name: svc1
stack_name: org/project1/stack1
work_dir: pulumi/project1
- service_name: svc`
stack_name: org/project`/stack2
work_dir: pulumi/project`
permissions:
id-token: write
contents: read
pull-requests: write
secrets: inherit
uses: ./.github/workflows/pulumi_preview_callee.yaml
with:
service_name: ${{ matrix.service_name }}
stack_name: ${{ matrix.stack_name }}
work_dir: ${{ matrix.work_dir }}
comment_on_pr: true
comment_on_pr_number: "${{ github.event.pull_request.number }}"
The callee
job then runs the pulumi action with inputs from caller
- uses: pulumi/actions@v3
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: preview
work-dir: ${{ inputs.work_dir }}
stack-name: "bluecodecom/${{ inputs.stack_name }}"
diff: true
comment-on-pr: ${{ inputs.comment_on_pr }}
comment-on-pr-number: ${{ fromJSON(inputs.comment_on_pr_number) }}
edit-pr-comment: true
Expected Behavior
Comment per stack appears on the PR.
Actual Behavior
The logs say that Not able to edit comment, defaulting to creating a new comment.
, however no comments anywhere.
Not able to edit comment, defaulting to creating a new comment.
(node:2037) UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration
at /home/runner/work/_actions/pulumi/actions/v3/webpack:/pulumi-github-action/node_modules/@octokit/request/dist-node/index.js:86:1
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2037) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2037) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Output of pulumi about
Action version:
Run pulumi/actions@v3
Configured range: ^3
Matched version: v3.51.0
Additional context
I suspect it may be related to #802
Another thing in logs is this
SyntaxError: Unexpected token e in JSON at position 0
warning: [runtime] Failed to parse engine event
If you're seeing this warning, please comment on https://github.com/pulumi/pulumi/issues/6768 with the event and any
details about your environment.
Event: tamp":1673854322,"diagnosticEvent":{"prefix":"debug: ","message":"RegisterResourceOutputs RPC finished: urn=urn:pulumi:stack:...; err: null, resp: \n","color":"never","severity":"debug"}}
SyntaxError: Unexpected token a in JSON at position 1
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
@RobbieMcKinstry Feel free to merge this with #802 if you find it related.
Thanks! I'll triage this issue when I'm back in office tomorrow :D
I'm really going to have to dig into this and the related comment-on-pr
issues ASAP.
I'm really going to have to dig into this and the related
comment-on-pr
issues ASAP.
@RobbieMcKinstry I'm sorry to hear that on the other hand, it makes me very happy! Let me know if I can be of any help and provide you with more detailed logs or run the release candidates.
I am also a member of Pulumi Community Slack, feel free to tag me there @jan
for real-time conversation.
@1oglop1 I've seen some similar weirdness in an unrelated project recently.
This is just a hunch, but try removing GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
from the env
block in your pulumi action step.
- uses: pulumi/actions@v3
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
# omitted: GITHUB_TOKEN
with:
command: preview
work-dir: ${{ inputs.work_dir }}
stack-name: "bluecodecom/${{ inputs.stack_name }}"
diff: true
comment-on-pr: ${{ inputs.comment_on_pr }}
comment-on-pr-number: ${{ fromJSON(inputs.comment_on_pr_number) }}
edit-pr-comment: true
All actions have implicit access to the token via ${{ github.token }}
, so you shouldn't need to pass it in anyway.
Background: I recently had a workflow where I tried to return a secret as the output for a reusable workflow—but GHA used the redacted version in the output, not the unreacted version. IF the same thing is happening here, then the pulumi/actions@v3
is being called with GITHUB_TOKEN set to the redacted token (***
), not the actual token.
It's a bit of a stretch, but it would explain why the (otherwise valid) token is being rejected.
Another thing in logs is this
SyntaxError: Unexpected token e in JSON at position 0 warning: [runtime] Failed to parse engine event If you're seeing this warning, please comment on https://github.com/pulumi/pulumi/issues/6768 with the event and any details about your environment. Event: tamp":1673854322,"diagnosticEvent":{"prefix":"debug: ","message":"RegisterResourceOutputs RPC finished: urn=urn:pulumi:stack:...; err: null, resp: \n","color":"never","severity":"debug"}} SyntaxError: Unexpected token a in JSON at position 1
I think this is probably unrelated to this issue—see https://github.com/pulumi/pulumi/issues/6768
I was facing the same issue.
I solved this by changing Settings -> Actions -> General -> Workflow
Permissions to allow read and write:
For me I fixed the error by adding pull-requests: write
permission to the job.
jobs:
pulumi:
name: Pulumi Preview
permissions:
contents: read
pull-requests: write # this line required
See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions