4

I have the environment created named "main", but the workflow below errors out: environment created: enter image description here

Below is my github workflow:

name: Deploy ADf ARM    

on:
  workflow_dispatch:

environment: 
  name: main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:

      # Checkout code
    - uses: actions/checkout@main
      ...

at present it notes the error:

The workflow is not valid. .github/workflows/deploy-adf-arm.yml (Line: 7, Col: 1): Unexpected value 'environment'

How can I reference this environment to work?

Sauron
  • 6,399
  • 14
  • 71
  • 136
  • 1
    Read the docs https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#env is the top level, you can only use https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idenvironment for *jobs* – jonrsharpe Jan 12 '21 at 22:01

1 Answers1

5

It should be on job level

name: Deploy ADf ARM    

on:
  workflow_dispatch:



jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    environment: 
      name: main
    steps:

      # Checkout code
    - uses: actions/checkout@main
      ...
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • Is there anyway to do the same thing but after a specific job step? – Sauron Jan 13 '21 at 15:30
  • Not using environments. Maybe there are something different solutions but I'm not aware of them. If possible split your tasks between two jobs. Then use env on the one where you expect approval. – Krzysztof Madej Jan 13 '21 at 16:29
  • I discovered that work around. But using environments, is there a way to pass a message from one job to another before the second has gotten started? like "these objects will be deleted", then approve and start the job? – Sauron Jan 13 '21 at 18:32