🔹 Step 1: Push Code to GitHub
What happens?
A developer commits code changes and pushes them to a branch (e.g., main
or dev
) on GitHub.
Trigger: This push acts as a trigger for GitHub Actions.
Example:
git add .
git commit -m "Added new API endpoint"
git push origin main
What happens?
GitHub Actions sees the push and starts a workflow (defined in .github/workflows/deploy.yml
).
Inside deploy.yml example:
name: Deploy to AWS
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
Colorful Idea: Think of this as a pipeline button that gets pressed automatically after every push.
What happens?
GitHub Action runner checks your code, installs dependencies, runs tests, and builds the project.
Example: (For Node.js app)
- name: Install Dependencies
run: npm install
- name: Run Tests
run: npm test
- name: Build Project
run: npm run build
✅ This ensures only tested and built code goes for deployment.
What happens?
GitHub Action needs permission to talk to AWS. This is done via AWS Access Key & Secret Key stored in GitHub Secrets.
Example:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1
Colorful Analogy: This is like giving GitHub a VIP Pass to enter AWS.
Here’s where the magic happens 💫
Depending on your app, you may deploy to:
EC2 (Virtual Machine)
ECS/Fargate (Containers)
Lambda (Serverless Functions)
S3 + CloudFront (Static Websites)
EKS (Kubernetes)
- name: Deploy to S3
run: aws s3 sync ./build s3://my-app-bucket --delete
👉 Uploads build files to S3 bucket for hosting.
- name: Build Docker Image
run: docker build -t my-app:latest .
- name: Push to ECR
run: |
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin <account_id>.dkr.ecr.ap-south-1.amazonaws.com
docker tag my-app:latest <account_id>.dkr.ecr.ap-south-1.amazonaws.com/my-app:latest
docker push <account_id>.dkr.ecr.ap-south-1.amazonaws.com/my-app:latest
- name: Update ECS Service
run: |
aws ecs update-service --cluster my-cluster --service my-service --force-new-deployment
👉 This builds a Docker image, pushes it to ECR, and tells ECS to deploy the new version.
- name: Zip & Deploy to Lambda
run: |
zip -r function.zip .
aws lambda update-function-code --function-name my-lambda-fn --zip-file fileb://function.zip
👉 This uploads your code package to Lambda.
Run smoke tests or health checks to confirm the deployment worked.
Example:
- name: Verify Deployment
run: curl -I https://myapp.com
✅ Ensures users get the updated version.
GitHub can notify via Slack, Teams, or Email when deployment succeeds/fails.
Example:
- name: Notify on Slack
uses: slackapi/slack-github-action@v1.23
with:
payload: '{"text":"🚀 Deployment successful!"}'
👨💻 Developer Push Code
⬇
⚡ GitHub Action Trigger
⬇
🛠️ Build & Test
⬇
🔐 Authenticate with AWS
⬇
🚀 Deploy to AWS (EC2 / ECS / Lambda / S3)
⬇
✅ Verify & Notify
👉 This is the end-to-end journey from GitHub to AWS Deployment.