This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Dispatcher Workflow | |
permissions: | |
contents: read | |
actions: read | |
id-token: write | |
on: | |
push: | |
branches-ignore: | |
- 'main' | |
jobs: | |
decide: | |
runs-on: ubuntu-latest | |
outputs: | |
trigger_create: ${{ steps.set_trigger.outputs.trigger_create }} | |
trigger_sanity_test: ${{ steps.set_trigger.outputs.trigger_sanity_test }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set flags for create channel and sanity test | |
id: set_trigger | |
run: './.github/workflows/dispatcher.sh' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GITHUB_SHA: ${{ github.sha }} | |
GITHUB_REF: ${{ github.ref }} | |
- name: results | |
run: | | |
echo "trigger_create: ${{ steps.set_trigger.outputs.trigger_create }}" | |
echo "trigger_sanity_test: ${{ steps.set_trigger.outputs.trigger_sanity_test }}" | |
run_create: | |
needs: decide | |
if: ${{ needs.decide.outputs.trigger_create == 'true' }} | |
uses: ./.github/workflows/create-channel.yml | |
secrets: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | |
AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | |
run_sanity_test: | |
needs: [decide, run_create] | |
if: ${{ needs.decide.outputs.trigger_sanity_test == 'true' && needs.decide.outputs.trigger_create == 'true' }} | |
uses: ./.github/workflows/sanity-test.yml | |
secrets: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | |
AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | |
run_sanity_test_only: | |
needs: decide | |
if: ${{ needs.decide.outputs.trigger_sanity_test == 'true' && needs.decide.outputs.trigger_create != 'true' }} | |
uses: ./.github/workflows/sanity-test.yml | |
secrets: | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | |
CRT_CI_ROLE_ARN: ${{ secrets.CRT_CI_ROLE_ARN }} | |
AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO }} | |
ensure_branch_protection: | |
needs: [decide, run_create, run_sanity_test, run_sanity_test_only] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check all jobs succeeded | |
run: | | |
for result in "${{ needs.run_create.result }}" "${{ needs.run_sanity_test.result }}" "${{ needs.run_sanity_test_only.result }}"; do | |
if [[ "$result" != "success" && "$result" != "skipped" ]]; then | |
echo "One or more jobs failed, were cancelled, or had errors (result: $result)" | |
exit 1 | |
fi | |
done | |
echo "All required jobs have completed successfully" |