Under settings in the repo created environment Variable Var1.
Below is github actions which will again call another template in different repo
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions
on:
workflow_dispatch:
inputs:
Pass_Input:
description: 'test'
required: true
default: "From Github action 2"
jobs:
call-workflow-passing-data:
env: prd
uses: your-org/your-repo/.github/workflows/option1.yml@main
with:
MT_NAME: "Calling from Github 2"
MT_FOLDER: ${{ vars.var1 }}
I get following error:
Invalid workflow file: .github/workflows/option2.yml#L13
The workflow is not valid.
.github/workflows/option2.yml (Line: 13, Col: 10): Unexpected value 'prd'
.github/workflows/option2.yml (Line: 14, Col: 5): Unexpected value 'uses'
Reference template of GHA is:
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions
on:
workflow_call:
inputs:
MT_NAME:
description: 'MT Name'
required: true
type: string
MT_FOLDER:
type: string
description: 'MT Folder location'
required: true
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- run: echo "${{ inputs.MT_NAME }}"
- run: echo "${{ inputs.MT_FOLDER }}"
Please can somebody help to fix this issue
I don't think you can pass the environment in the calling workflow the way you do, you'll need to convert that to an input as well. Plus, to pass an environment you need to use
environment:and notenv:, the latter is for setting a job level environment variable, the former is to link a job to an environment defined in github. I know, confusing as hell.The following workflow works for me:
and
Be sure to create the variable at the Repository level, you can't pass in an Environment level variable, as the calling workflow doesn't have access to the environment!
Result:
If the variable you're trying to reference is stored at the environment level...
You need to use a slightly different syntax:
Then reference it in the callable workflow as follows:
That will allow you to reference the variable stored at the environment through the input of the callable workflow.