Skip to content

Commit ac1f606

Browse files
committed
Fix GitHub Actions workflow - correct output format and error handling
1 parent 1d912dd commit ac1f606

1 file changed

Lines changed: 13 additions & 36 deletions

File tree

β€Ž.github/workflows/deploy-apprunner.ymlβ€Ž

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,52 +61,23 @@ jobs:
6161
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
6262
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
6363
64-
echo "Image URI: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
65-
66-
- name: Create apprunner.yaml for ECR deployment
67-
run: |
68-
cat > apprunner-ecr.yaml << EOF
69-
version: 1.0
70-
runtime: docker
71-
build:
72-
commands:
73-
build:
74-
- echo "Using pre-built Docker image"
75-
run:
76-
runtime-version: latest
77-
command: python run_server.py
78-
network:
79-
port: 8000
80-
env: PORT
81-
env:
82-
- name: FLASK_ENV
83-
value: "production"
84-
- name: FLASK_DEBUG
85-
value: "0"
86-
- name: PORT
87-
value: "8000"
88-
- name: API_KEYS
89-
value: "demo_basic_key:DemoBasic:basic,demo_premium_key:DemoPremium:premium"
90-
- name: MASTER_API_KEY
91-
value: "demo_master_key_12345"
92-
- name: LOG_LEVEL
93-
value: "INFO"
94-
EOF
64+
# Output image URI
65+
echo "image-uri=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
9566
9667
- name: Deploy to App Runner (if service exists)
9768
env:
9869
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
9970
run: |
10071
# Check if App Runner service exists
101-
SERVICE_ARN=$(aws apprunner list-services --query "ServiceSummaryList[?ServiceName=='permit-api-service'].ServiceArn | [0]" --output text --region $AWS_REGION)
72+
SERVICE_ARN=$(aws apprunner list-services --query "ServiceSummaryList[?ServiceName=='permit-api-service'].ServiceArn | [0]" --output text --region $AWS_REGION 2>/dev/null || echo "None")
10273
103-
if [ "$SERVICE_ARN" != "None" ] && [ "$SERVICE_ARN" != "" ]; then
74+
if [ "$SERVICE_ARN" != "None" ] && [ "$SERVICE_ARN" != "" ] && [ "$SERVICE_ARN" != "null" ]; then
10475
echo "Updating existing App Runner service..."
10576
aws apprunner start-deployment --service-arn $SERVICE_ARN --region $AWS_REGION
10677
echo "Deployment started for service: $SERVICE_ARN"
10778
else
108-
echo "No existing App Runner service found. Please create service manually using:"
109-
echo "Image URI: $ECR_REGISTRY/$ECR_REPOSITORY:latest"
79+
echo "No existing App Runner service found."
80+
echo "Create service manually using image URI: $ECR_REGISTRY/$ECR_REPOSITORY:latest"
11081
fi
11182
11283
- name: Output deployment info
@@ -115,4 +86,10 @@ jobs:
11586
run: |
11687
echo "πŸš€ Deployment completed!"
11788
echo "πŸ“¦ Docker Image: $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
118-
echo "πŸ”— Use this image URI in App Runner console: $ECR_REGISTRY/$ECR_REPOSITORY:latest"
89+
echo "πŸ”— Use this image URI in App Runner console:"
90+
echo " $ECR_REGISTRY/$ECR_REPOSITORY:latest"
91+
echo ""
92+
echo "πŸ“‹ Next steps:"
93+
echo "1. Go to AWS App Runner console"
94+
echo "2. Create service with Container Registry source"
95+
echo "3. Use image URI: $ECR_REGISTRY/$ECR_REPOSITORY:latest"

0 commit comments

Comments
Β (0)