name: Komodo Deployment Trigger on: workflow_run: workflows: ["Docker Image CI"] types: - completed branches: [ "**_deploy", "main" ] jobs: trigger_komodo_deployment: runs-on: ubuntu-latest # Only run if the 'Docker Image CI' workflow was successful if: github.event.workflow_run.conclusion == 'success' steps: - name: Extract branch name from triggering workflow id: branch run: echo "BRANCH_NAME=$(echo ${{ github.event.workflow_run.head_branch }} | sed 's/\//-/g')" >> $GITHUB_OUTPUT - name: Trigger Komodo Stack Deployment env: # The webhook URL is constructed from secrets KOMODO_WEBHOOK_URL: "https://${{ secrets.KOMODO_HOST }}/listener/github/stack/${{ secrets.KOMODO_STACK_ID_OR_NAME }}/deploy" run: | # Get the branch name from the previous step's output branch_name="${{ steps.branch.outputs.BRANCH_NAME }}" # Construct a JSON payload containing the branch name # This tells Komodo which specific branch/tag to deploy payload=$(printf '{"ref":"%s"}' "$branch_name") # Generate the signature based on the payload signature=$(echo -n "$payload" | openssl dgst -sha256 -hmac "${{ secrets.KOMODO_WEBHOOK_SECRET }}" | sed 's/^.* //') # Send the request to the Komodo webhook with the payload echo "Triggering StrategIQ deployment for branch: $branch_name" curl -X POST \ -H "Content-Type: application/json" \ -H "X-Hub-Signature-256: sha256=$signature" \ -d "$payload" \ --fail-with-body \ "${KOMODO_WEBHOOK_URL}"