Skip to content

Latest commit

 

History

History
77 lines (49 loc) · 2.79 KB

parameters.md

File metadata and controls

77 lines (49 loc) · 2.79 KB

Parameters

Given the highly customizable nature of the branch-deploy Action, users may often find that they need to pass in a number of parameters into subsequent steps during their deployments. This Action provides a way to pass in parameters to the .deploy command without any required structure or format.

Example

Here are a few examples of how to pass in parameters to the .deploy command and why they might be used.

Example 1

Command:

.deploy to development | LOG_LEVEL=debug,CPU_CORES=4

Outputs:

  • params = LOG_LEVEL=debug,CPU_CORES=4
  • parsed_params = ["LOG_LEVEL=debug,CPU_CORES=4"]

Why: A user might need to deploy to the development environment and tell subsequent workflow steps to use a LOG_LEVEL of debug and CPU_CORES of 4.

Example 2

Command:

.deploy | something1 something2 something3

Outputs:

  • params = something1 something2 something3
  • parsed_params = ["something1", "something2", "something3"]

Why: This example shows that the params output is just a string that can be literally anything your heart desires. It is up to the user to parse the string and use it in subsequent steps.

Example 3

Command:

.deploy | --cpu=2 --memory=4G --env=development --port=8080 --name=my-app -q my-queue

Outputs:

  • params = --cpu=2 --memory=4G --env=development --port=8080 --name=my-app -q my-queue
  • parsed_params = {_: [], cpu: 2, memory: '4G', env: 'development', port: 8080, name: 'my-app', q: 'my-queue'}

Why: This example shows that by using structure within your params string like --key=value, they can be automatically parsed into a JSON object and saved as the parsed_params output. This can be useful for users that want to pass in a number of parameters to their deployment and have them automatically parsed and saved as a JSON object as an output of this Action. Having machine readable output can be quite useful for subsequent workflow steps.

Parameter Separator

The param_separator input defaults to | and will collect any text that is provided after this character and save it as a GitHub Actions output called params. This output can then be used in subsequent steps.

This value can be configured to be any character (or string) that you want.

Parameter Output

The params and parsed_params outputs can be accessed just like any other output from the branch-deploy Action. Here is a quick example:

- name: branch-deploy
  id: branch-deploy
  uses: github/[email protected]
  with:
    trigger: .deploy
    param_separator: "|"

- name: example
  if: steps.branch-deploy.outputs.continue == 'true'
  run: |
    echo "params: ${{ steps.branch-deploy.outputs.params }}"
    echo "parsed_params: ${{ steps.branch-deploy.outputs.parsed_params }}"