Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by Sid for Passing env variable inputs to a reusable workflow

Lately GitHub introduced a feature to support variables in environment (very basic and the long awaited feature, I must say).
So other solution could be to create an environment in GitHub, create some variables under it with desired values and use the environment as needed.

Caller workflow:

jobs:  Dev-Deployment:    uses: ./.github/workflows/reusable-workflow.yml    with:        environment: Development  QA-Deployment:    uses: ./.github/workflows/reusable-workflow.yml    with:        environment: QA

Reusable workflow:

on: workflow_call:  inputs:    environment:      type: string      required: truejobs:  deploy:    runs-on: ubuntu-latest    environment: ${{ inputs.environment }}    steps:      - name: Print variables - ${{ vars.SOME_VAR }} - ${{ vars.ANOTHER_VAR }}        run: |            echo ${{ vars.SOME_VAR }}            echo ${{ vars.ANOTHER_VAR }}

GitHub environment:

Image may be NSFW.
Clik here to view.
enter image description here


Viewing all articles
Browse latest Browse all 7

Trending Articles