From 7622e30063f79f8c6b17e520f80388578214631c Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:36:58 +0000 Subject: [PATCH 01/13] Added pass-action-output-to-job-environment workflow --- .../action-with-output-from-env/action.yml | 17 +++++++++++++++++ .github/workflows/deployment-status-update.yml | 1 - .../pass-action-output-to-job-environment.yml | 16 ++++++++++++++++ .github/workflows/step-outputs-in-action.yml | 1 - 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .github/actions/action-with-output-from-env/action.yml create mode 100644 .github/workflows/pass-action-output-to-job-environment.yml diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml new file mode 100644 index 0000000..dff8893 --- /dev/null +++ b/.github/actions/action-with-output-from-env/action.yml @@ -0,0 +1,17 @@ +name: action-with-output-from-env +description: Action With Output From Env + +outputs: + url: + description: "Deployment URL" + value: ${{ env.URL }} + +runs: + using: composite + steps: + - name: step one + id: step-one + shell: bash + run: | + echo "URL is https://example.com" + echo "URL=https://example.com" >> $GITHUB_ENV diff --git a/.github/workflows/deployment-status-update.yml b/.github/workflows/deployment-status-update.yml index c7befce..95d0b1e 100644 --- a/.github/workflows/deployment-status-update.yml +++ b/.github/workflows/deployment-status-update.yml @@ -1,7 +1,6 @@ name: DeploymentStatusUpdate on: - pull_request: workflow_dispatch: inputs: fail-deployment: diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml new file mode 100644 index 0000000..518e6c8 --- /dev/null +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -0,0 +1,16 @@ +name: PassActionOutputToJobEnvironment + +on: + pull_request: + workflow_dispatch: + +jobs: + test: + name: Pass Action Output To Job Environment + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.4.0 + + - name: Step Outputs In Action + uses: ./.github/actions/action-with-output-from-env/ diff --git a/.github/workflows/step-outputs-in-action.yml b/.github/workflows/step-outputs-in-action.yml index d2d61bd..718e21d 100644 --- a/.github/workflows/step-outputs-in-action.yml +++ b/.github/workflows/step-outputs-in-action.yml @@ -1,7 +1,6 @@ name: StepOutputsInAction on: - pull_request: workflow_dispatch: jobs: From 5eb2c6c08b44d9f822b8fb49d0e20b8fc6cb335d Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:38:54 +0000 Subject: [PATCH 02/13] Added environment to workflow --- .github/workflows/pass-action-output-to-job-environment.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index 518e6c8..dfcdf30 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -7,6 +7,9 @@ on: jobs: test: name: Pass Action Output To Job Environment + environment: + name: Test + url: ${{ steps.step-one.outputs.url }} runs-on: ubuntu-latest steps: - name: Checkout From 64c353710a4f099151a50916c26c20af7d50ddb7 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:44:18 +0000 Subject: [PATCH 03/13] Changed step id from step in action to step in workflow --- .github/actions/action-with-output-from-env/action.yml | 4 ++-- .github/workflows/pass-action-output-to-job-environment.yml | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml index dff8893..5b57f7c 100644 --- a/.github/actions/action-with-output-from-env/action.yml +++ b/.github/actions/action-with-output-from-env/action.yml @@ -9,8 +9,8 @@ outputs: runs: using: composite steps: - - name: step one - id: step-one + - name: step inside action + id: step-inside-action shell: bash run: | echo "URL is https://example.com" diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index dfcdf30..84b2877 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -9,11 +9,12 @@ jobs: name: Pass Action Output To Job Environment environment: name: Test - url: ${{ steps.step-one.outputs.url }} + url: ${{ steps.call-action-step.outputs.url }} runs-on: ubuntu-latest 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/ From f95d350d878d684466206d65c62c897055bd0efb Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:46:22 +0000 Subject: [PATCH 04/13] Added stept to echo output --- .github/workflows/pass-action-output-to-job-environment.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index 84b2877..c487bf4 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -18,3 +18,6 @@ jobs: - name: Step Outputs In Action id: call-action-step uses: ./.github/actions/action-with-output-from-env/ + + - name: Echo Output + run: echo "Output: ${{ steps.call-action-step.outputs.url }}" From b9f69f0afad89240c45b9b704953c142f53df0fe Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:49:39 +0000 Subject: [PATCH 05/13] Simplified step --- .github/workflows/pass-action-output-to-job-environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index c487bf4..31ab6d4 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -20,4 +20,4 @@ jobs: uses: ./.github/actions/action-with-output-from-env/ - name: Echo Output - run: echo "Output: ${{ steps.call-action-step.outputs.url }}" + run: echo ${{ steps.call-action-step.outputs.url }} From 82f31c1ec63baa207fdbad2ad61c88557d28a47e Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:52:11 +0000 Subject: [PATCH 06/13] Echo env var directly --- .github/workflows/pass-action-output-to-job-environment.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index 31ab6d4..99ea8f1 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -9,7 +9,7 @@ jobs: name: Pass Action Output To Job Environment environment: name: Test - url: ${{ steps.call-action-step.outputs.url }} + url: ${{ env.URL }} runs-on: ubuntu-latest steps: - name: Checkout @@ -20,4 +20,6 @@ jobs: uses: ./.github/actions/action-with-output-from-env/ - name: Echo Output - run: echo ${{ steps.call-action-step.outputs.url }} + run: | + echo ${{ steps.call-action-step.outputs.url }} + echo ${{ env.URL }} From 5deaf811cc3a9318617147ce4e8a41368bfdda92 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 11:56:30 +0000 Subject: [PATCH 07/13] Echoed inside action output --- .github/workflows/pass-action-output-to-job-environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index 99ea8f1..f6989a0 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -21,5 +21,6 @@ jobs: - name: Echo Output run: | + echo ${{ steps.step-inside-action.outputs.url }} echo ${{ steps.call-action-step.outputs.url }} echo ${{ env.URL }} From f5e9689ce3dab7fd5138ec6ee90649e81be03c9e Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 13:35:26 +0000 Subject: [PATCH 08/13] Use ::set-output in action --- .github/actions/action-with-output-from-env/action.yml | 8 ++++++-- .../workflows/pass-action-output-to-job-environment.yml | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml index 5b57f7c..87f45c6 100644 --- a/.github/actions/action-with-output-from-env/action.yml +++ b/.github/actions/action-with-output-from-env/action.yml @@ -2,9 +2,12 @@ name: action-with-output-from-env description: Action With Output From Env outputs: - url: - description: "Deployment URL" + 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 @@ -15,3 +18,4 @@ runs: run: | echo "URL is https://example.com" echo "URL=https://example.com" >> $GITHUB_ENV + echo "::set-output name=step-url::https://example.com" diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index f6989a0..5d68109 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -21,6 +21,8 @@ jobs: - name: Echo Output run: | - echo ${{ steps.step-inside-action.outputs.url }} - echo ${{ steps.call-action-step.outputs.url }} + 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 }} From f0a1d9015f960443f1238191826cfbfaf06af628 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 13:45:26 +0000 Subject: [PATCH 09/13] Added echo step inside action --- .github/actions/action-with-output-from-env/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml index 87f45c6..f11cc94 100644 --- a/.github/actions/action-with-output-from-env/action.yml +++ b/.github/actions/action-with-output-from-env/action.yml @@ -19,3 +19,8 @@ runs: echo "URL is https://example.com" echo "URL=https://example.com" >> $GITHUB_ENV echo "::set-output name=step-url::https://example.com" + + - name: echo step inside action output + id: echo-step-inside-action-output + shell: bash + run: echo steps.step-inside-action.outputs.step-url From 13a65c4bebc78ef0000d54d25619a0340488c0c9 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 13:48:47 +0000 Subject: [PATCH 10/13] Added expression syntax --- .github/actions/action-with-output-from-env/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml index f11cc94..0d0bb9c 100644 --- a/.github/actions/action-with-output-from-env/action.yml +++ b/.github/actions/action-with-output-from-env/action.yml @@ -23,4 +23,4 @@ runs: - name: echo step inside action output id: echo-step-inside-action-output shell: bash - run: echo steps.step-inside-action.outputs.step-url + run: echo ${{ steps.step-inside-action.outputs.step-url }} From 3070035108080fc49d11c0052f39aa152a166677 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 14:17:09 +0000 Subject: [PATCH 11/13] Use matrix strategy --- .github/workflows/pass-action-output-to-job-environment.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index 5d68109..fb7e6f1 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -8,9 +8,12 @@ jobs: test: name: Pass Action Output To Job Environment environment: - name: Test + name: ${{ matrix.environment }} url: ${{ env.URL }} runs-on: ubuntu-latest + strategy: + matrix: + environment: [Test,Staging] steps: - name: Checkout uses: actions/checkout@v2.4.0 From 231fb2902425cef60a27caaf7dcafc8adaf477cc Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 14:22:30 +0000 Subject: [PATCH 12/13] Added environment input to action --- .github/actions/action-with-output-from-env/action.yml | 10 +++++++--- .../pass-action-output-to-job-environment.yml | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/actions/action-with-output-from-env/action.yml b/.github/actions/action-with-output-from-env/action.yml index 0d0bb9c..588dc7a 100644 --- a/.github/actions/action-with-output-from-env/action.yml +++ b/.github/actions/action-with-output-from-env/action.yml @@ -1,6 +1,10 @@ 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" @@ -16,9 +20,9 @@ runs: id: step-inside-action shell: bash run: | - echo "URL is https://example.com" - echo "URL=https://example.com" >> $GITHUB_ENV - echo "::set-output name=step-url::https://example.com" + 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 diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index fb7e6f1..e858d07 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -21,6 +21,8 @@ jobs: - 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: | From caf485163f4936d44595e9065342da857d8a1250 Mon Sep 17 00:00:00 2001 From: NickGraham101 Date: Tue, 22 Mar 2022 14:31:46 +0000 Subject: [PATCH 13/13] Set environment url from step outputs --- .github/workflows/pass-action-output-to-job-environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pass-action-output-to-job-environment.yml b/.github/workflows/pass-action-output-to-job-environment.yml index e858d07..83f713c 100644 --- a/.github/workflows/pass-action-output-to-job-environment.yml +++ b/.github/workflows/pass-action-output-to-job-environment.yml @@ -9,7 +9,7 @@ jobs: name: Pass Action Output To Job Environment environment: name: ${{ matrix.environment }} - url: ${{ env.URL }} + url: ${{ steps.call-action-step.outputs.output-url }} runs-on: ubuntu-latest strategy: matrix: