-
Notifications
You must be signed in to change notification settings - Fork 455
Unexpected token 'var' #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
👋 Hey @tjbaker What event is this workflow triggering on? It's possible that If it's helpful, you can print out the full - name: Comment on PR
uses: actions/github-script@v5
if: failure()
with:
script: |
console.log(JSON.stringify(context.issue))
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "foo"
}) |
It is triggered on pull_request
I can't try the additional debugging just yet... |
Ok, I think the actual problem is with using a multiline output from a previous step's stdout as the body in createComment. The problem is trying to make hashicorp/setup-terraform work with github-script@v5 and github.rest.issues.createComment. There is an example in the readme, but it is against actions/[email protected] |
@tjbaker did you resolve your issue? |
If you need to pass into multi-line outputs into the Example: - uses: actions/github-script@v5
env:
MULTILINE_VALUE: ${{ steps.my_step.outputs.value }}
with:
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.MULTILINE_VALUE
}) |
I am having this issue where the error message is:
My step looks like: - name: Post comment
uses: actions/github-script@v6
with:
script: |
const comment = '
Data for `${{ steps.get_id.outputs.an_id }}`:
```json
${{ steps.get_data.outputs.result }}
```';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
}) Where |
@jsumners are you able to pass that JSON object as an environment variable instead? |
No. I moved on to writing the data to a file with JavaScript and then |
Going to close this issue out. If anyone sees an error like this, it usually means that the JavaScript is invalid in some way. Usually this occurs when using the Actions expression syntax ( The workaround is to process this input indirectly, rather than inserting it directly into your script. This can be done by writing it to a file or using an Feel free to open a new issue if you're still having issues after trying those workarounds. |
So I encountered this same issue and was able to resolve it using below as per @joshmgross's recommendation
|
This workflow is a direct consequence of the asynchronous release schedule of pydantic and pydantic core and the fact that pydantic is always pinned to a particular pydantic-core version. Dependabot doesn't see these transitive relations and so can't properly update the versions in this case (it always assumes the latest for every dependency). This will naturally lead to broken CI making these version updates impossible to merge. Since our project directly only cares about pydantic and not pydantic-core, we can ignore pydantic-core updates (future patch) and run a dedicated workflow on every dependabot pull request that would check whether changes to our requirements files are needed. If changes are needed, the GitHub actions bot will comment on the pull request that a change to these files are needed and provide a patch to the reviewer to apply and update the pull request. The workflow is only executed when changes to the requirements files are proposed (realistically only by dependabot). Note that it's not possible to specify the source branch as the workflow trigger, only the target branch, and so that could not have been used as a better filter for dependabot-proposed pull requests specifically. It is run using a Python Alpine docker image, saves the git diff produced by pip-compile to the default github actions environment followed by a github script action that will pop the diff out of the environment and use it to comment on the pull request. References: - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings - https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution - https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue - actions/github-script#247 (comment) - actions/github-script#220 (comment) Signed-off-by: Erik Skultety <[email protected]>
This workflow is a direct consequence of the asynchronous release schedule of pydantic and pydantic core and the fact that pydantic is always pinned to a particular pydantic-core version. Dependabot doesn't see these transitive relations and so can't properly update the versions in this case (it always assumes the latest for every dependency). This will naturally lead to broken CI making these version updates impossible to merge. Since our project directly only cares about pydantic and not pydantic-core, we can ignore pydantic-core updates (future patch) and run a dedicated workflow on every dependabot pull request that would check whether any additional changes (i.e. transitive dependency version locks) to our requirements files are needed. If so, then the GitHub actions bot will comment on the pull request that a change to these files is needed and will provide a patch to the reviewer to apply and update the pull request. The workflow is only executed when changes to the requirements files are proposed (realistically only by dependabot). Note that it's not possible to specify the source branch as the workflow trigger, only the target branch, and so that could not have been used as a better filter for dependabot-proposed pull requests specifically. It is run using a Python Alpine docker image, saves the git diff produced by pip-compile to the default github actions environment followed by a github script action that will pop the diff out of the environment and use it to comment on the pull request. References: - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings - https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution - https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue - actions/github-script#247 (comment) - actions/github-script#220 (comment) Signed-off-by: Erik Skultety <[email protected]>
This workflow is a direct consequence of the asynchronous release schedule of pydantic and pydantic core and the fact that pydantic is always pinned to a particular pydantic-core version. Dependabot doesn't see these transitive relations and so can't properly update the versions in this case (it always assumes the latest for every dependency). This will naturally lead to broken CI making these version updates impossible to merge. Since our project directly only cares about pydantic and not pydantic-core, we can ignore pydantic-core updates (future patch) and run a dedicated workflow on every dependabot pull request that would check whether any additional changes (i.e. transitive dependency version locks) to our requirements files are needed. If so, then the GitHub actions bot will comment on the pull request that a change to these files is needed and will provide a patch to the reviewer to apply and update the pull request. The workflow is only executed when changes to the requirements files are proposed (realistically only by dependabot). Note that it's not possible to specify the source branch as the workflow trigger, only the target branch, and so that could not have been used as a better filter for dependabot-proposed pull requests specifically. It is run using a Python Alpine docker image, saves the git diff produced by pip-compile to the default github actions environment followed by a github script action that will pop the diff out of the environment and use it to comment on the pull request. References: - https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#multiline-strings - https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution - https://github.com/actions/github-script?tab=readme-ov-file#comment-on-an-issue - actions/github-script#247 (comment) - actions/github-script#220 (comment) Signed-off-by: Erik Skultety <[email protected]>
I am trying to comment on a PR via a workflow and keep getting this exception:
The code is really simple
Github support asked me to log a bug report here as well.
The text was updated successfully, but these errors were encountered: