Skip to content
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

context "github" is not allowed here. no context is available here. #500

Closed
lucacome opened this issue Jan 3, 2025 · 4 comments
Closed

Comments

@lucacome
Copy link

lucacome commented Jan 3, 2025

It seems like this new check is not working correctly. From what I can tell from the docs github is always available.

I know for sure that it works in the code snippet below because I've had it for years.

      - name: Build binary
        uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
        with:
          version: v2.5.0 
          args: ${{ github.ref_type == 'tag' && 'release' || 'build --snapshot' }} --clean
@azazeal
Copy link

azazeal commented Jan 3, 2025

There's more false positives being reported in the latest release (v1.7.5). For example, one of our builds that uses actionlint broke due to the recent changes. This is an excerpt of the the build I mentioned:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    env:
      PGPASSWORD: ${{ github.sha }}

    services:
      pg:
        image: postgres:11-alpine
        env:
          POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
        ports:
          - 5432
        options: >-
          --health-cmd "pg_isready -d postgres -U postgres"
          --health-interval 1s
          --health-timeout 1s
          --health-retries 10

This build sets up a Postgres instance with a specific password (the SHA of the commit that triggered it) and used to work as the rest of the suite was able to connect to it using a non-default password.

Checking the notes of the latest release one reads the following:

For example, jobs..env allows github context but jobs..services..env doesn't allow any contexts. Now actionlint can catch the mistake.

While the error that our build breaks with now is as follows:

.github/workflows/test.yml:18:34: context "env" is not allowed here. no context is available here. see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details [expression]
   |
18 |           POSTGRES_PASSWORD: ${{ env.PGPASSWORD }}
   |                                  ^~~~~~~~~~~~~~

However, following the link (ref) we can clearly see that jobs.<job_id>.services.<service_id>.env.<env_id> supports—among other things—the env context.

@rhysd
Copy link
Owner

rhysd commented Jan 3, 2025

Closing as duplicate of #495.

Regarding to the issue by @azazeal, I'll check it tomorrow before releasing the next version. Thanks for the report.

@rhysd rhysd closed this as completed Jan 3, 2025
@azazeal
Copy link

azazeal commented Jan 3, 2025

Closing as duplicate of #495.

Regarding to the issue by @azazeal, I'll check it tomorrow before releasing the next version. Thanks for the report.

Much obliged. Thanks!

@rhysd
Copy link
Owner

rhysd commented Jan 4, 2025

v1.7.6 for fixing this issue was released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants