diff --git a/.github/workflows/ci-dispatch-job.yml b/.github/workflows/ci-dispatch-job.yml index 16ee905cbba..22eb78071c3 100644 --- a/.github/workflows/ci-dispatch-job.yml +++ b/.github/workflows/ci-dispatch-job.yml @@ -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} @@ -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}}') @@ -130,5 +141,4 @@ jobs: ${{inputs.command}}" - name: Mark job as successful id: done - shell: bash run: echo "SUCCESS=true" | tee -a ${GITHUB_OUTPUT} diff --git a/.github/workflows/ci-dispatch-two-stage.yml b/.github/workflows/ci-dispatch-two-stage.yml index c4dd2aef76d..dda70fcfa2d 100644 --- a/.github/workflows/ci-dispatch-two-stage.yml +++ b/.github/workflows/ci-dispatch-two-stage.yml @@ -32,6 +32,7 @@ jobs: consumers: needs: producers + if: ${{ !cancelled() && needs.producers.outputs.success }} permissions: id-token: write contents: read