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

Unable to use env variable in a container name #2394

Open
lukasz-mitka opened this issue Jan 25, 2023 · 2 comments
Open

Unable to use env variable in a container name #2394

lukasz-mitka opened this issue Jan 25, 2023 · 2 comments
Labels
bug Something isn't working keep Label can be added as soon as we are sure the work on the issue is necessary triaged Needs extra internal investigation before adding ready-for-dev

Comments

@lukasz-mitka
Copy link

lukasz-mitka commented Jan 25, 2023

Describe the bug
I'm trying to use env variable inside container name and I'm getting Startup Failures.

To Reproduce
Use env variable in a container name specifier. Example:

name: env in container name

on:
  push:

env:
  IMAGE: ubuntu:18.04

jobs:
  build:
    runs-on: ubuntu-latest
    container: ${{ env.IMAGE }}
    steps:
      - name: env
        run: echo ${{ env.IMAGE }}

Expected behavior
Workflow should start with container from env.IMAGE
env context should be available: https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability

Runner Version and Platform

Can't tell, it doesn't start.

OS: Linux

What's not working?

Workflow doesn't start.

Status Startup failure

Invalid workflow file: .github/workflows/env_container_name.yaml#L12
The workflow is not valid. .github/workflows/env_container_name.yaml (Line: 12, Col: 16): Unrecognized named-value: 'env'. Located at position 1 within expression: env.IMAGE

Found this and it's missing env:

"container": {
"context": [
"github",
"needs",
"strategy",
"matrix",
"vars"

Job Log Output

n/a

Runner and Worker's Diagnostic Logs

n/a

@lukasz-mitka lukasz-mitka added the bug Something isn't working label Jan 25, 2023
@nikola-jokic nikola-jokic added keep Label can be added as soon as we are sure the work on the issue is necessary triaged Needs extra internal investigation before adding ready-for-dev labels Jan 25, 2023
@fhammerl
Copy link
Contributor

Hey @lukasz-mitka, thanks for submitting this one. It does seem like there's a mismatch between what's documented and what's possible.

Since the process of parsing the yaml includes both runner- and server-side operations, we won't be able to resolve this issue immediately with just a runner PR / change.

I will post an update here once we're at that point.

@renakdup
Copy link

Jobs has no access to env variables, but steps can access. It's frustrated me.
I agree that we need to fix this issue, that looks unlogical, and a lot of developers waste time reinventing the wheel.

I found related issues, and this issue was not solved since 2021: #1189

Solving this problem can provide Github action more flexibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working keep Label can be added as soon as we are sure the work on the issue is necessary triaged Needs extra internal investigation before adding ready-for-dev
Projects
None yet
Development

No branches or pull requests

4 participants