Skip to content

Commit

Permalink
docs: document compose-output step
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <[email protected]>
  • Loading branch information
hiddeco committed Jan 13, 2025
1 parent b2afe4a commit a6e49d7
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions docs/docs/35-references/10-promotion-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -1596,4 +1596,60 @@ steps:
The `http` step only produces the outputs described by the `outputs` field of
its configuration.

### `compose-output`

`compose-output` is a step that composes a new output from one or more existing
outputs. This step can be useful when subsequent steps need to reference a
combination of outputs from previous steps, or to allow a
[`PromotionTask`](30-promotion-tasks.md) to provide easy access to outputs from
the steps it contains.

### `compose-output` Configuration

The `compose-output` step accepts an arbitrary set of key-value pairs, where the
key is the name of the output to be created and the value is arbitrary and can
be an [Expression Language](./20-expression-language.md) expression.

#### `compose-output` Example

```yaml
vars:
- name: repoURL
value: https://github.com/example/repo.git
steps:
- uses: git-open-pr
as: open-pr
config:
repoURL: ${{ vars.repoURL }}
createTargetBranch: true
sourceBranch: ${{ outputs.push.branch }}
targetBranch: stage/${{ ctx.stage }}
- uses: compose-output
as: pr-link
config:
url: ${{ vars.repoURL }}/pull/${{ outputs['open-pr'].prNumber }}
- uses: http
config:
method: POST
url: https://slack.com/api/chat.postMessage
headers:
- name: Authorization
value: Bearer ${{ secrets.slack.token }}
- name: Content-Type
value: application/json
body: |
${{ quote({
"channel": "C123456",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "A new PR has been opened: ${{ outputs['pr-link'].url }}"
}
}
]
}) }}
```

[expr-lang]: https://expr-lang.org/

0 comments on commit a6e49d7

Please sign in to comment.