Skip to content

Commit

Permalink
Parse context array dynamic exit code (#2)
Browse files Browse the repository at this point in the history
* Added input for step two exit code

* Removed step env var mapping

* Use double square brackets in condition
  • Loading branch information
NickGraham101 authored Mar 3, 2022
1 parent 62e0689 commit 81f1242
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
17 changes: 9 additions & 8 deletions .github/actions/parse-context-array/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: parse-context-array
description: Parse Context Array

inputs:
step-two-exit-code:
required: true

runs:
using: composite
steps:
Expand All @@ -12,27 +16,24 @@ runs:
- name: step two
id: step-two
shell: bash
run: exit 0
run: exit ${{ inputs.step-two-exit-code }}

- name: Evaluate job one status
- name: Echo job statuses
if: always()
shell: bash
run: |
echo $STEP_OUTCOMES
env:
STEP_OUTCOMES: ${{ steps.step-one.outcome }}
echo ${{ steps.step-one.outcome }}
echo ${{ steps.step-two.outcome }}
- name: Evaluate job status
if: always()
shell: bash
run: |
if [ $STEP_OUTCOMES =~ "failure" ]; then
if [[ ${{ join(steps.*.outcome, ',') }} =~ "failure" ]]; then
echo JOB_STATUS="failure" >> $GITHUB_ENV;
else
echo JOB_STATUS="success" >> $GITHUB_ENV;
fi;
env:
STEP_OUTCOMES: ${{ join(steps.*.outcome, ',') }}
- name: Report job status
if: always()
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/parse-context-array.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: ParseContextArray

on: [push]
on:
workflow_dispatch:
inputs:
step-two-exit-code:
type: number
default: 0
push:

jobs:
test:
Expand All @@ -12,3 +18,5 @@ jobs:

- name: Parse Context Array
uses: ./.github/actions/parse-context-array/
with:
step-two-exit-code: ${{ github.event.inputs.step-two-exit-code }}

0 comments on commit 81f1242

Please sign in to comment.