Skip to content

Commit afa8462

Browse files
committed
chore: DEV 환경 롤링 배포 수정
1 parent 57963d1 commit afa8462

2 files changed

Lines changed: 51 additions & 51 deletions

File tree

.github/workflows/cicd-workflow.yml

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -65,56 +65,56 @@ jobs:
6565
# sudo apt-get update
6666
# sudo apt-get install -y awscli
6767

68-
# AWS SSM으로 현재 redis의 포트 확인 커멘드 설정
69-
- name: Get Redis port from AWS SSM
70-
if: github.ref == 'refs/heads/develop'
71-
id: send_cmd
72-
run: |
73-
cmd_id=$(aws ssm send-command \
74-
--document-name "AWS-RunShellScript" \
75-
--targets "Key=instanceIds,Values=${{ secrets.EC2_INSTANCE_ID }}" \
76-
--comment "Deploy script via CI" \
77-
--parameters 'commands=[
78-
"if netstat -tuln | grep -q \":6379 \"; then echo 6379; \
79-
elif netstat -tuln | grep -q \":6380 \"; then echo 6380; \
80-
else echo none; fi"
81-
]' \
82-
--region ap-northeast-2 \
83-
--query "Command.CommandId" --output text)
84-
echo "cmd_id=$cmd_id" >> $GITHUB_OUTPUT
85-
86-
# AWS SSM 커멘드를 실행하여 현재 redis의 포트 확인 및 교체할 port 저장
87-
- name: Get Redis port command result
88-
if: github.ref == 'refs/heads/develop'
89-
id: get_cmd_result
90-
run: |
91-
redis_port=$(aws ssm get-command-invocation \
92-
--command-id ${{ steps.send_cmd.outputs.cmd_id }} \
93-
--instance-id ${{ secrets.EC2_INSTANCE_ID }} \
94-
--region ap-northeast-2 \
95-
--query 'StandardOutputContent' \
96-
--output text | tr -d '\n')
97-
echo "현재 열려있는 Redis 포트: $redis_port"
98-
if [ "$redis_port" = "6379" ]; then
99-
next_port="6380"
100-
elif [ "$redis_port" = "6380" ]; then
101-
next_port="6379"
102-
else
103-
next_port="6379"
104-
echo "Redis를 신규로 띄웁니다"
105-
fi
106-
echo "next_redis_port=$next_port" >> $GITHUB_OUTPUT
107-
108-
# 호스트 포트 수정
109-
- name: Update Redis hostPort in task-definition-dev.json
110-
if: github.ref == 'refs/heads/develop'
111-
run: |
112-
jq --arg port "${{ steps.get_cmd_result.outputs.next_redis_port }}" \
113-
'(.containerDefinitions[] | select(.name == "redis-dev").portMappings[] | select(.containerPort == 6379)).hostPort = ($port | tonumber)' \
114-
task-definition-dev.json > tmp.json && mv tmp.json task-definition-dev.json
115-
116-
echo "수정된 task-definition.json의 Redis portMappings:"
117-
jq '.containerDefinitions[] | select(.name == "redis-dev") | .portMappings[].hostPort' task-definition-dev.json
68+
# # AWS SSM으로 현재 redis의 포트 확인 커멘드 설정
69+
# - name: Get Redis port from AWS SSM
70+
# if: github.ref == 'refs/heads/develop'
71+
# id: send_cmd
72+
# run: |
73+
# cmd_id=$(aws ssm send-command \
74+
# --document-name "AWS-RunShellScript" \
75+
# --targets "Key=instanceIds,Values=${{ secrets.EC2_INSTANCE_ID }}" \
76+
# --comment "Deploy script via CI" \
77+
# --parameters 'commands=[
78+
# "if netstat -tuln | grep -q \":6379 \"; then echo 6379; \
79+
# elif netstat -tuln | grep -q \":6380 \"; then echo 6380; \
80+
# else echo none; fi"
81+
# ]' \
82+
# --region ap-northeast-2 \
83+
# --query "Command.CommandId" --output text)
84+
# echo "cmd_id=$cmd_id" >> $GITHUB_OUTPUT
85+
#
86+
# # AWS SSM 커멘드를 실행하여 현재 redis의 포트 확인 및 교체할 port 저장
87+
# - name: Get Redis port command result
88+
# if: github.ref == 'refs/heads/develop'
89+
# id: get_cmd_result
90+
# run: |
91+
# redis_port=$(aws ssm get-command-invocation \
92+
# --command-id ${{ steps.send_cmd.outputs.cmd_id }} \
93+
# --instance-id ${{ secrets.EC2_INSTANCE_ID }} \
94+
# --region ap-northeast-2 \
95+
# --query 'StandardOutputContent' \
96+
# --output text | tr -d '\n')
97+
# echo "현재 열려있는 Redis 포트: $redis_port"
98+
# if [ "$redis_port" = "6379" ]; then
99+
# next_port="6380"
100+
# elif [ "$redis_port" = "6380" ]; then
101+
# next_port="6379"
102+
# else
103+
# next_port="6379"
104+
# echo "Redis를 신규로 띄웁니다"
105+
# fi
106+
# echo "next_redis_port=$next_port" >> $GITHUB_OUTPUT
107+
#
108+
# # 호스트 포트 수정
109+
# - name: Update Redis hostPort in task-definition-dev.json
110+
# if: github.ref == 'refs/heads/develop'
111+
# run: |
112+
# jq --arg port "${{ steps.get_cmd_result.outputs.next_redis_port }}" \
113+
# '(.containerDefinitions[] | select(.name == "redis-dev").portMappings[] | select(.containerPort == 6379)).hostPort = ($port | tonumber)' \
114+
# task-definition-dev.json > tmp.json && mv tmp.json task-definition-dev.json
115+
#
116+
# echo "수정된 task-definition.json의 Redis portMappings:"
117+
# jq '.containerDefinitions[] | select(.name == "redis-dev") | .portMappings[].hostPort' task-definition-dev.json
118118

119119
# - name: Update spring.data.redis.port in application.yml
120120
# if: github.ref == 'refs/heads/develop'

task-definition-dev.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
{
5454
"name": "redis-dev-6379-tcp",
5555
"containerPort": 6379,
56-
"hostPort": 6379,
56+
"hostPort": 0,
5757
"protocol": "tcp"
5858
}
5959
],

0 commit comments

Comments
 (0)