Skip to content

Commit

Permalink
Hotfix: CD 쉘스크립트 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tioon committed Apr 27, 2024
1 parent 3a8d4dc commit 25553ce
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:
SECRET_KEY: ${{ secrets.NAVER_SECRET_KEY }}
run: |
cd baebae-BE
chmod +x request_source_deploy.sh
./request_source_deploy.sh
chmod +x request_source_deploy_start.sh
./request_source_deploy_start.sh
37 changes: 37 additions & 0 deletions baebae-BE/request_source_deploy_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Function to sign the request
function Sign_Request() {
local api_server=$1
local api_url=$2
local apicall_method=$3
local ncloud_accesskey=$4
local ncloud_secretkey=$5

local unixtimestamp=$(echo $(($(date +%s%N)/1000000)))
local message="${apicall_method} ${api_url}\n${unixtimestamp}\n${ncloud_accesskey}"

local signature=$(echo -n -e "$message"|iconv -t utf8 |openssl dgst -sha256 -hmac "$ncloud_secretkey" -binary|openssl enc -base64)

echo -e "x-ncp-apigw-timestamp:$unixtimestamp\nx-ncp-iam-access-key:$ncloud_accesskey\nx-ncp-apigw-signature-v2:$signature"
}

# Sample API server and URL
api_server="https://vpcsourcedeploy.apigw.ntruss.com"
api_url="/api/v1/project/$PROJECT_ID/stage/$STAGE_ID/scenario/$SCENARIO_ID/deploy"
apicall_method="POST"
ncloud_accesskey=$ACCESS_KEY
ncloud_secretkey=$SECRET_KEY
api_full_url="${api_server}${api_url}"

# Get the headers from the Sign_Request function
headers=$(Sign_Request "$api_server" "$api_url" "$apicall_method" "$ncloud_accesskey" "$ncloud_secretkey")

# Prepare header arguments for curl
header_args=()
while IFS= read -r line; do
header_args+=("-H" "$line")
done <<< "$headers"

# Make the API request
curl -X "$apicall_method" "$api_full_url" "${header_args[@]}"

0 comments on commit 25553ce

Please sign in to comment.