Skip to content

Parse an ini-style configuration block to easily set env or outputs.

License

Notifications You must be signed in to change notification settings

someimportantcompany/github-actions-ini-config

Repository files navigation

ini-config

GitHub CICD Coverage

Given an ini-style configuration block, parse the contents & assign relevant environment variables / output in your GitHub Workflow.

Usage

- uses: someimportantcompany/github-actions-ini-config@v1
  id: config
  with:
    config: |
      ; Defaults, applied on each run
      [env]
      SOMETHING = true
      [outputs]
      stage = dev

      ; Production config
      [(${{ github.ref == "refs/heads/main" }}).env]
      NODE_ENV = production
      [(${{ github.ref == "refs/heads/main" }}).outputs]
      branch = main
      stage = prod

      ; Development config
      [(${{ github.ref == "refs/heads/develop" }}).env]
      NODE_ENV = development
      [(${{ github.ref == "refs/heads/develop" }}).outputs]
      branch = develop
      stage = dev

      ; Other config
      [(${{ github.ref == "refs/heads/release/v1" }}).outputs]
      branch = release/v1
      stage = release

# if github.ref == "refs/heads/main"
- run: echo ${{ env.NODE_ENV }} # production
- run: echo ${{ steps.config.outputs.branch }} # develop
- run: echo ${{ steps.config.outputs.stage }} # prod

# if github.ref == "refs/heads/develop"
- run: echo ${{ env.NODE_ENV }} # development
- run: echo ${{ steps.config.outputs.branch }} # develop
- run: echo ${{ steps.config.outputs.stage }} # dev

# if github.ref == "refs/heads/release/v1"
- run: echo ${{ env.NODE_ENV }} # null
- run: echo ${{ steps.config.outputs.branch }} # release/v1
- run: echo ${{ steps.config.outputs.stage }} # release

# if github.ref == "refs/heads/feature/something"
- run: echo ${{ env.NODE_ENV }} # null
- run: echo ${{ steps.config.outputs.branch }} # null
- run: echo ${{ steps.config.outputs.stage }} # dev

Inputs

Key Description
config Required. An ini-style configuration block to parse.

Syntax

[(${{ /* Workflow Expression */ }}).$section]

Provide a suitable GitHub Workflow between the brackets (), and choose either env or outputs for the section. This gives you the full range of expressions, contexts & variables.

Notes

About

Parse an ini-style configuration block to easily set env or outputs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published