EC2-READ-LOGTAIL #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: EC2-READ-LOGTAIL | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| read-log: | |
| name: Read CodeDeploy LogTail | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Get latest deployment logTail | |
| run: | | |
| echo "=== 최근 배포 목록 ===" | |
| DEPLOYMENTS=$(aws deploy list-deployments \ | |
| --application-name runnect-prod-codedeploy \ | |
| --deployment-group-name runnect-prod-codedeploy-group \ | |
| --query "deployments[:3]" \ | |
| --output text 2>/dev/null) | |
| echo "Deployments: $DEPLOYMENTS" | |
| for DEP_ID in $DEPLOYMENTS; do | |
| echo "" | |
| echo "================================================" | |
| echo "=== Deployment: $DEP_ID ===" | |
| DEP_STATUS=$(aws deploy get-deployment --deployment-id "$DEP_ID" \ | |
| --query "deploymentInfo.status" --output text 2>/dev/null) | |
| DEP_TIME=$(aws deploy get-deployment --deployment-id "$DEP_ID" \ | |
| --query "deploymentInfo.createTime" --output text 2>/dev/null) | |
| echo "Status: $DEP_STATUS | Created: $DEP_TIME" | |
| INSTANCES=$(aws deploy list-deployment-instances \ | |
| --deployment-id "$DEP_ID" \ | |
| --query "instancesList" \ | |
| --output text 2>/dev/null) | |
| for INST in $INSTANCES; do | |
| echo "" | |
| echo "--- Instance: $INST ---" | |
| aws deploy get-deployment-instance \ | |
| --deployment-id "$DEP_ID" \ | |
| --instance-id "$INST" \ | |
| --query "instanceSummary.lifecycleEvents[].{name:lifecycleEventName, status:status, logTail:diagnostics.logTail}" \ | |
| --output json 2>&1 | |
| done | |
| done |