Skip to content

Commit

Permalink
Adding new success checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Apr 22, 2024
1 parent 290575d commit 2290522
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/ci-dispatch-job.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
name: "CI/Dispatch/Job"

# Important note about depending on this workflow: The `result` will be a failure, even if successful.
#
# This reusable workflow dispatches to a number of internal jobs. Only one job will run,
# and some may be in error states due to empty matrices (which are used instead of `if` to keep
# skipped dispatch jobs out of the GHA UI). The `continue-on-error` flag should prevent these
# errors from failing the workflow, but this does not work.
#
# Thus, the `result` of this workflow will always be a failure, even if the job itself is successful.
# To depend on this job, you should use the `success` output instead:
#
# ```
# dependent_job:
# needs: dispatch-job
# if: ${{ !cancelled() && needs.dispatch-job.outputs.success }}
# ```

defaults:
run:
shell: bash
shell: bash -euo pipefail {0}

on:
workflow_call:
outputs:
# To check for success of this job, evaluate the following outputs. If any are true, the job succeeded.
linux_success:
value: ${{ jobs.linux.outputs.success }}
windows_success:
value: ${{ jobs.windows.outputs.success }}
success:
value: ${{ contains(toJSON(jobs.*.outputs.success), 'true') }}
inputs:
dispatch: {type: string, required: true}
name: {type: string, required: true}
Expand Down Expand Up @@ -110,10 +123,8 @@ jobs:
aws-region: us-east-2
role-duration-seconds: 43200 # 12 hours
- name: Fetch ${{ inputs.image }}
shell: powershell
run: docker pull ${{ inputs.image }}
- name: Run Command
shell: powershell
run: >-
docker run ${{ inputs.image }} powershell -c "[System.Environment]::SetEnvironmentVariable('AWS_ACCESS_KEY_ID','${{env.AWS_ACCESS_KEY_ID}}')
[System.Environment]::SetEnvironmentVariable('AWS_SECRET_ACCESS_KEY','${{env.AWS_SECRET_ACCESS_KEY}}')
Expand All @@ -130,5 +141,4 @@ jobs:
${{inputs.command}}"
- name: Mark job as successful
id: done
shell: bash
run: echo "SUCCESS=true" | tee -a ${GITHUB_OUTPUT}
1 change: 1 addition & 0 deletions .github/workflows/ci-dispatch-two-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:

consumers:
needs: producers
if: ${{ !cancelled() && needs.producers.outputs.success }}
permissions:
id-token: write
contents: read
Expand Down

0 comments on commit 2290522

Please sign in to comment.