Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pass-action-output-to-job-environment workflow #10

Merged
merged 13 commits into from
Apr 13, 2022
30 changes: 30 additions & 0 deletions .github/actions/action-with-output-from-env/action.yml
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 }}
1 change: 0 additions & 1 deletion .github/workflows/deployment-status-update.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: DeploymentStatusUpdate

on:
pull_request:
workflow_dispatch:
inputs:
fail-deployment:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/pass-action-output-to-job-environment.yml
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 }}
1 change: 0 additions & 1 deletion .github/workflows/step-outputs-in-action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: StepOutputsInAction

on:
pull_request:
workflow_dispatch:

jobs:
Expand Down