Supporting `actions/github-script` step named outputs
Is your feature request related to a problem? Please describe.
When using https://github.com/actions/github-script with a call to core.setOutput(), the VSCode extension is unable to do autocompletion and shows "Context access might be invalid" warnings.
The usual way of setting outputs with actions/github-script is to use a return statement, which creates a result output, accessible with steps.<step-id>.outputs.result (https://github.com/actions/github-script#reading-step-results).
But we preferred to use the reference to the core API to set named outputs instead.
Example:
- uses: actions/github-script@v6
id: get-versions
with:
script: |
const currentVersion = 'v1.0.0'
const nextVersion = 'v1.1.0'
core.setOutput('CURRENT_VERSION', currentVersion)
core.setOutput('NEXT_VERSION', nextVersion)
- name: Use versions
run: |
echo "Current version: ${{ steps.get-version.outputs.CURRENT_VERSION }}"
echo "Next version: ${{ steps.get-version.outputs.NEXT_VERSION }}"
Describe the solution you'd like
The VSCode extension should be able to read the inline scripts passed to your official actions/github-script action, and detect all the calls to core.setOutput() to provide autocompletion.
And realistically, I can understand that https://github.com/actions/github-script#run-a-separate-file would be a limitation. Trying to find all require statements, reading those files recursively, etc. would be too much for this VSCode extension. Or you would have to include some kind of bundling to find all the core.setOutput() in the import tree.
By the way, the echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_OUTPUT syntax in inline bash scripts is supported. We have autocompletion for steps.<step-id>.outputs.CURRENT_VERSION (that's cool btw! 🤩)
So it may be an extra reason to also support core.setOutput().
Ran into this today. It would be nice to at least mark these in a way to make the error go away if full support cannot be implemented.
If I only need to return one single value, the direct script return makes sense. But if I need to return multiple values, there is no need to return stringified json that then must be parsed using fromJSON to extract them. A direct set output is simply cleaner and more readable.
Its a shame this ticket has been rotting close to a year now. I guess I will just have to live with this extension screaming at me.