Skip to content

Commit c763247

Browse files
committed
fix: Repair YAML workflow and enhance AWS deployment diagnostics
1 parent 2d9f656 commit c763247

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

.github/workflows/ci-cd.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,29 @@ jobs:
120120
run: |
121121
echo "🚀 Starting deployment process..."
122122
echo "📍 AWS Region: ${{ env.AWS_REGION }}"
123-
echo "� ECR Repository: ${{ env.ECR_REPOSITORY }}"
124-
echo "🔑 AWS Credentials: Configured ✅"
123+
echo "📦 ECR Repository: ${{ env.ECR_REPOSITORY }}"
124+
echo "🔑 Checking AWS Credentials..."
125+
126+
# Verify secrets are available (without exposing them)
127+
if [ -z "${{ secrets.AWS_ACCESS_KEY_ID }}" ]; then
128+
echo "❌ AWS_ACCESS_KEY_ID is missing"
129+
exit 1
130+
else
131+
echo "✅ AWS_ACCESS_KEY_ID is available"
132+
fi
133+
134+
if [ -z "${{ secrets.AWS_SECRET_ACCESS_KEY }}" ]; then
135+
echo "❌ AWS_SECRET_ACCESS_KEY is missing"
136+
exit 1
137+
else
138+
echo "✅ AWS_SECRET_ACCESS_KEY is available"
139+
fi
140+
141+
if [ -z "${{ secrets.API_KEY }}" ]; then
142+
echo "⚠️ API_KEY is missing - using default"
143+
else
144+
echo "✅ API_KEY is available"
145+
fi
125146
126147
- name: Set up Python
127148
uses: actions/setup-python@v5
@@ -135,11 +156,24 @@ jobs:
135156
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
136157
aws-region: ${{ env.AWS_REGION }}
137158

159+
- name: Test AWS connection
160+
run: |
161+
echo "🧪 Testing AWS connection..."
162+
aws sts get-caller-identity
163+
echo "✅ AWS connection successful!"
164+
138165
- name: Setup SAM CLI
139166
uses: aws-actions/setup-sam@v2
140167
with:
141168
use-installer: true
142169

170+
- name: Create ECR repository if not exists
171+
run: |
172+
echo "📦 Ensuring ECR repository exists..."
173+
aws ecr describe-repositories --repository-names ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }} || \
174+
aws ecr create-repository --repository-name ${{ env.ECR_REPOSITORY }} --region ${{ env.AWS_REGION }}
175+
echo "✅ ECR repository ready"
176+
143177
- name: Login to Amazon ECR
144178
id: login-ecr
145179
uses: aws-actions/amazon-ecr-login@v2
@@ -149,12 +183,21 @@ jobs:
149183
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
150184
IMAGE_TAG: ${{ github.sha }}
151185
run: |
186+
echo "🔨 Building Docker image..."
152187
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
188+
echo "📤 Pushing to ECR..."
153189
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
154190
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
155191
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
192+
echo "✅ Docker image pushed successfully!"
156193
157194
- name: Deploy to AWS Lambda
158195
run: |
196+
echo "🚀 Starting SAM deployment..."
159197
sam build --region ${{ env.AWS_REGION }}
160-
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name neurobank-api --capabilities CAPABILITY_IAM --region ${{ env.AWS_REGION }} --parameter-overrides ApiKey=${{ secrets.API_KEY }}
198+
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset \
199+
--stack-name neurobank-api \
200+
--capabilities CAPABILITY_IAM \
201+
--region ${{ env.AWS_REGION }} \
202+
--parameter-overrides ApiKey=${{ secrets.API_KEY || 'default-api-key' }}
203+
echo "🎉 Deployment completed successfully!"

0 commit comments

Comments
 (0)