DEV Community

Marcus Chukwuoma
Marcus Chukwuoma

Posted on

5 3

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.

USAGE

Variables

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

- uses: marcdomain/set-variables@v1
    with:
      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.

Output

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

Links

https://github.com/marketplace/actions/set-variables

If you would like to buy me coffee β˜•οΈ 😍

https://www.buymeacoffee.com/marcdomain

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs