-
Notifications
You must be signed in to change notification settings - Fork 60.5k
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
Explain how to unset failure code in composite actions #31356
Comments
@jsoref Thanks for opening this issue! I'll get this triaged for review ✨ |
I know that you cannot unset an failure code, however composite action 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
This step has conclusion success unless you decide to make another step let it fail For me it looks like that composite action have almost no good documentation |
Thanks for calling this out @jsoref! I agree that it makes sense to add an example for how to set exit codes in composite actions to the end of this article. You or anyone is welcome to open a pull request to make that change! |
Ok, here's the best I've managed: Prepare all required actions
Run ./
Run echo Hello World.
Hello World.
Run exit $(( $RANDOM % 2 ))
Error: Process completed with exit code 1.
Run echo step maybe-die outcome: $out
step maybe-die outcome: failure
Run echo goodbye
goodbye
Prepare all required actions
Run ./
Run echo Hello World.
Hello World.
Run exit $(( $RANDOM % 2 ))
Error: Process completed with exit code 1.
Run echo step maybe-die outcome: $out
step maybe-die outcome: failure
Run echo goodbye
goodbye
Prepare all required actions
Run ./
Run echo Hello World.
Hello World.
Run exit $(( $RANDOM % 2 ))
Run echo step maybe-die outcome: $out
step maybe-die outcome: success
Run echo goodbye
goodbye
Prepare all required actions
Run ./
Run echo Hello World.
Hello World.
Run exit $(( $RANDOM % 2 ))
Run echo step maybe-die outcome: $out
step maybe-die outcome: success
Run echo goodbye
goodbye
name: CI
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Debug action
run: grep -n . ./action.yml
- name: Run action
uses: ./
- name: Run action
uses: ./
- name: Run action
uses: ./
- name: Run action
uses: ./
- name: Run action
uses: ./
- name: Run action
uses: ./ 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: maybe-die
run: exit $(( $RANDOM % 2 ))
shell: bash
continue-on-error: true
- run: echo true
if: failure()
shell: bash
- if: failure() || success()
shell: bash
run: |
echo step maybe-die outcome: $out
env:
out: ${{ steps.maybe-die.outcome }}
- run: echo goodbye
shell: bash Note that as an action author, I do not want my random subprocesses' exit codes to appear in Annotations And I have no idea how to suppress that. Or rather, I'm 99% confident that I just plain can't, which sucks: I think an extra flag for |
Here's the version of things I'm going to use as the basis of my documentation https://github.com/check-spelling-sandbox/composite-failures-0/actions/runs/8174941452 |
Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/actions/creating-actions/setting-exit-codes-for-actions
What part(s) of the article would you like to see updated?
Add a section about composite actions -- specifically how to set a 0 exit code for cases where an intermediate step (actions/download-artifact being my canonical example) fail
Additional information
Here's a sample run: https://github.com/check-spelling-sandbox/composite-failures-0/actions/runs/7717700123/job/21037354247
workflow:
action
https://github.com/check-spelling-sandbox/composite-failures-0/actions/runs/7717700123/job/21037354247
The text was updated successfully, but these errors were encountered: