Closed LucasMMota closed 10 months ago
@LucasMMota can you share your workflow file?
@joshmgross
name: Run CI job on dbt Cloud
on:
pull_request_review: # triggers on PR approval
types:
- submitted
jobs:
run-job:
name: job name
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: "actions/checkout@v3"
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Python set up
uses: "actions/setup-python@v4"
with:
python-version: "3.9"
... other steps removed here
- name: Comment failure in PR
uses: "actions/github-script@v6"
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: **Job run failed**. Approvals dismissed. Please check
})
@LucasMMota it looks like you have an unclosed string in your body
argument:
body: ':x: **Job run failed**. Approvals dismissed. Please check
Could you try body: ':x: **Job run failed**. Approvals dismissed. Please check'
and see if that fixes your issue?
Sorry, I updated the code just to exemplify, that'd be the real step (it has no error in this sense):
- name: Comment failure in PR
if: steps.monitor_job.outputs.run_succeeded != 'true'
uses: "actions/github-script@v6"
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: **Job run failed**. Approvals dismissed. Please check: ${{ steps.trigger_job.outputs.run_status_link }}'
})
It's possible something in that output isn't being escaped and breaking the JS syntax, could you try:
- name: Comment failure in PR
if: steps.monitor_job.outputs.run_succeeded != 'true'
uses: "actions/github-script@v6"
env:
RUN_STATUS_LINK: ${{ steps.trigger_job.outputs.run_status_link }}
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: **Job run failed**. Approvals dismissed. Please check: ${ process.env.RUN_STATUS_LINK }'
})
I updated and it's like this, but same error continues happening 🤔 (it worths it to mention that it runs gracefully in the first time and break in the second:
First step (ok):
- name: Comment link in PR
uses: "actions/github-script@v6"
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':link: **Job run in dbt cloud:** ${{ steps.trigger_job.outputs.run_status_link }}'
})
Second step (failing):
- name: Comment failure in PR
if: steps.monitor_job.outputs.run_succeeded != 'true'
uses: "actions/github-script@v6"
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: **Job run failed**. Approvals dismissed. Please check run in the dbt cloud.'
})
exit 1
Just checked that other workflows that run once, post the comment successfully.
Only this one that posts twice is failing.
It seems something on the "actions/github-script@v6"
on the second post.
@LucasMMota that exit 1
in your second step is not valid JavaScript
The closest analogue in Node would be process.exit(1)
The actions/core
library providers a wrapper around that with core.SetFailed
which also allows you to pass a message:
- name: Comment failure in PR
if: steps.monitor_job.outputs.run_succeeded != 'true'
uses: "actions/github-script@v6"
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: ':x: **Job run failed**. Approvals dismissed. Please check run in the dbt cloud.'
})
core.setFailed('Job run failed')
thank you @joshmgross, your solution solved the problem
Describe the bug The step is failing with the error:
SyntaxError: Unexpected number
To Reproduce I'm not sure this is intermittent or not
Expected behavior post comment on PR