actions / actions/runner

Unable to use `env` variable in a container name

Open
#2,394 2 comments 21 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug keep triaged
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

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: https://github.com/actions/runner/blob/ca7be16dd3b90be39775987995ce4c9dd8bdf7d8/src/Sdk/DTPipelines/workflow-v1.0.json#L367-L373

Job Log Output

n/a

Runner and Worker's Diagnostic Logs

n/a

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the workflow example in .github/workflows/env_container_name.yaml at line 12 and inspect the referenced workflow-v1.0.json schema around its container name definition. Confirm how context availability is represented for container expressions, then verify that the workflow accepts env.IMAGE and starts with the requested container.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.