-
Notifications
You must be signed in to change notification settings - Fork 93
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
Support Custom GitHub Action use of GITHUB_ENV #47
Comments
Another example:
|
Same here; additions to Here's a workflow snippet with the same warning on every steps:
- name: Add environment variable
run: echo REF=${string/--*/} >> $GITHUB_ENV
- name: Reference environment variable
if: env.REF != 'default' # Context access might be invalid: REF
uses: actions/github-script@v6
with:
script: return "${{ env.REF }}" # Context access might be invalid: REF Thank you. |
I understand this warning in that there is probably no way for the extension to determine that the var will exist at runtime, so it will never be able to definitively know when to warn or not. So I think what we need is a way to tell the extension not to warn on certain vars, perhaps even scoped. Probably something comment based like other linters use., maybe a name: "Context access might be invalid"
on: push
jobs:
context-access-might-be-invalid:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup environment variables
uses: rlespinasse/github-slug-action@v4
# noqa: runtime-reference GITHUB_REF_SLUG
- name: Print custom environment variables
run: echo ${{ env.GITHUB_REF_SLUG }} Scoping would be neat, like somehow applying the WorkaroundThis can be worked around by explicitly adding the variable to an name: "Context access might be invalid"
on: push
env:
GITHUB_REF_SLUG: ""
jobs:
context-access-might-be-invalid:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup environment variables
uses: rlespinasse/github-slug-action@v4
- name: Print custom environment variables
run: echo ${{ env.GITHUB_REF_SLUG }} This is not a great workaround imo, because it masks the real issue, and means littering the workflow with useless references. Worse, it makes it more difficult to understand the workflow. There are also some errors with the variable flagging (it misses some!) which I'll raise in another issue. |
Fixed in next release: #61 (comment) |
Considering its supposedly to be fixed , I'm closing! |
#61 is an issue, not a PR so it can it fix anything itself. Perhaps what you mean is that actions/languageservices#15 fixes #61, but that doesn't seem entirely relevant here. Short-circuit evaluation is not even mentioned in this issue (but is mentioned in #61). So does #61 (actually actions/languageservices#15) really fix all of the problems described in this issue? actions/languageservices#15 only mentions the problem with short-circuit operators (which is not even described in this issue, but is described in #61)? |
You are correct and my closing of this was too hasty. Re-opening and re-evaluating. Sorry about that. |
Any updates for this issue ? |
Is this a confirmed bug others are getting? I loaded up visual studio code today to work on workflows, and I have this error everywhere, yet it's pulling info fine on Github. |
This is an upstream issue of the LSP, right? actions/languageservices#60 |
Is your feature request related to a problem? Please describe.
Some GitHub Actions use
GITHUB_ENV
to set up custom environment variables.When used inside a workflow, use
${{ env.CUSTOM_VARIABLE }}
is flagged asContext access might be invalid
.Describe the solution you'd like
Enable the custom GitHub Actions developer to define statically or dynamically the generated environment variables (like for the action output) and use it in this plugin to remove false-positive.
Additional context
This workflow is flagged with the issue
And produces
The text was updated successfully, but these errors were encountered: