DEV Community

Marcus Chukwuoma
Marcus Chukwuoma

Posted on


Github Actions: set-variables

set-variables is a Github Action for setting multiple variables dynamically. It also accepts the ternary operator syntax VARIABLE_NAME: conditional_statement ? true : false.



Variable names are dynamic - you're free to name your variables as you wish.

- uses: marcdomain/set-variables@v1
      variables: |
        ENVIRONMENT: "${{ github.ref }}" == "refs/heads/main" ? "production" : "staging"
        USERNAME: 1 > 2 ? "John" : "Doe"
Enter fullscreen mode Exit fullscreen mode

NOTE: Only string, number, and boolean data types are accepted in the conditions/values. The maximum number of variables allowed is 10.


Outputs are the resolved variables. In the example above, you can get the expected values with ${{ env.ENVIRONMENT }} and ${{ env.USERNAME }} respectively.


If you would like to buy me coffee ☕️ 😍

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.