runner icon indicating copy to clipboard operation
runner copied to clipboard

github context not available in environnment

Open wichert opened this issue 4 years ago • 3 comments

Describe the bug

I want to use a workflow for deployment to different environments. This workflow takes the environment as input using workflow dispatch:

on:
  workflow_dispatch:
    inputs:
      env:
        description: Environment to deploy to
        required: true
        default: dev

jobs:
  deploy:
    name: Update active theme
    environment: ${{ github.event.inputs.env }}

This fails with an error:

The workflow is not valid. .github/workflows/deploy.yaml (Line: 21, Col: 18): Unrecognized named-value: 'github'. Located at position 1 within expression: github.event.inputs.env

To Reproduce Steps to reproduce the behavior:

  1. Create a workflow with a workflow-dispatch trigger
  2. Add a job with an environment reference a dispatch input, for example environment: ${{ github.event.inputs.env }}
  3. Trigger the workflow

Expected behavior I would expect it to be possible to use event input to set the job environment.

Runner Version and Platform

GitHub Enterprise 3.1.7

What's not working?

The github context is not available when evaluation the expression for environment in a job.

wichert avatar Nov 01 '21 13:11 wichert

There is an unexpected workaround: the github context is available in the jobs.environment.name field.

jobs:
  deploy:
    name: Update active theme
    environment: 
      name: ${{ github.event.inputs.env }}

wichert avatar Nov 01 '21 13:11 wichert

There is a related GitHub Community thread for this issue.

wichert avatar Nov 01 '21 13:11 wichert

This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 15 days.

github-actions[bot] avatar Mar 25 '24 00:03 github-actions[bot]

This issue was closed because it has been stalled for 15 days with no activity.

github-actions[bot] avatar May 27 '24 00:05 github-actions[bot]