-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pass-action-output-to-job-environment workflow (#10)
* Added pass-action-output-to-job-environment workflow * Added environment to workflow * Changed step id from step in action to step in workflow * Added stept to echo output * Simplified step * Echo env var directly * Echoed inside action output * Use ::set-output in action * Added echo step inside action * Added expression syntax * Use matrix strategy * Added environment input to action * Set environment url from step outputs
- Loading branch information
1 parent
2ed9413
commit c2e7dd8
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: action-with-output-from-env | ||
description: Action With Output From Env | ||
|
||
inputs: | ||
environment: | ||
required: true | ||
|
||
outputs: | ||
env-url: | ||
description: "URL from action env var" | ||
value: ${{ env.URL }} | ||
output-url: | ||
description: "URL from step output" | ||
value: ${{ steps.step-inside-action.outputs.step-url }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: step inside action | ||
id: step-inside-action | ||
shell: bash | ||
run: | | ||
echo "URL is https://example.com/${{ inputs.environment }}" | ||
echo "URL=https://example.com/${{ inputs.environment }}" >> $GITHUB_ENV | ||
echo "::set-output name=step-url::https://example.com/${{ inputs.environment }}" | ||
- name: echo step inside action output | ||
id: echo-step-inside-action-output | ||
shell: bash | ||
run: echo ${{ steps.step-inside-action.outputs.step-url }} |
33 changes: 33 additions & 0 deletions
33
.github/workflows/pass-action-output-to-job-environment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: PassActionOutputToJobEnvironment | ||
|
||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Pass Action Output To Job Environment | ||
environment: | ||
name: ${{ matrix.environment }} | ||
url: ${{ steps.call-action-step.outputs.output-url }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
environment: [Test,Staging] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Step Outputs In Action | ||
id: call-action-step | ||
uses: ./.github/actions/action-with-output-from-env/ | ||
with: | ||
environment: ${{ matrix.environment }} | ||
|
||
- name: Echo Output | ||
run: | | ||
echo ${{ steps.step-inside-action.outputs.env-url }} | ||
echo ${{ steps.call-action-step.outputs.env-url }} | ||
echo ${{ env.URL }} | ||
echo ${{ steps.step-inside-action.outputs.output-url }} | ||
echo ${{ steps.call-action-step.outputs.output-url }} |