This workflow automates deploying a Docker-based application to Amazon ECS whenever changes are pushed to the main branch, sets up QEMU for multi-platform builds, and Docker Buildx for building and pushing Docker images. It configures AWS CLI using credentials stored in GitHub Secrets and registers a new task definition revision in ECS, including two containers: one for MongoDB database and another for the application itself. The script updates the ECS service to use the newly registered task definition, ensuring that the ECS service runs the latest version of the application. Another workflow is created to run every ten minutes, five times after deployment, checking CloudWatch alarms for CPU utilization, memory utilization, and HTTP 5xx errors. If any issues are detected, the rollback to the previous task will be triggered. The script monitors specific CloudWatch alarms and sets an output variable, alarm_state, to “ALARM” if any are triggered, determining whether the rollback should proceed. If any alarms are in the “ALARM” state, it retrieves the second-to-last task definition revision for the ECS service, representing the previous stable deployment, and updates the ECS service using this ARN, effectively rolling back to a prior version of the application.