forked from actions/runner
-
-
Notifications
You must be signed in to change notification settings - Fork 17
Continue on error of a step in composite actions
ChristopherHX edited this page Feb 17, 2024
·
1 revision
Composite action support continue-on-error
for all run + uses steps (has been added way after uses support)
Then you can query the outcome yourself
https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context
name: 'Hello World'
description: 'Greet someone'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
random-number:
description: "Random number"
value: ${{ steps.random-number-generator.outputs.random-number }}
runs:
using: "composite"
steps:
- run: echo Hello ${{ inputs.who-to-greet }}.
shell: bash
- id: random-number-generator
run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: bash
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- run: goodbye.sh
shell: bash
continue-on-error: true
id: may-fail
- run: echo ${{ steps.may-fail.outcome }}
shell: bash
Prepare all required actions
##[group]Run ./
with:
who-to-greet: World
##[endgroup]
##[group]Run echo Hello World.
echo Hello World.
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
Hello World.
##[group]Run echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
##[group]Run echo "/home/ubuntu/actions-runner-v2.283.4/_work/composite-action-with-continue-on-error/composite-action-with-continue-on-error/./" >> $GITHUB_PATH
echo "/home/ubuntu/actions-runner-v2.283.4/_work/composite-action-with-continue-on-error/composite-action-with-continue-on-error/./" >> $GITHUB_PATH
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
##[group]Run goodbye.sh
goodbye.sh
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
/home/ubuntu/actions-runner-v2.283.4/_work/_temp/31e0fff1-f95b-41a1-be92-bf1be82162fd.sh: line 1: goodbye.sh: command not found
##[error]Process completed with exit code 127.
##[group]Run echo failure
echo failure
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
##[endgroup]
failure
This step has conclusion success unless you decide to make another step let it fail