Skip to content

Commit

Permalink
Merge pull request #21 from Team-baebae/feature/cd/#20
Browse files Browse the repository at this point in the history
Feature/cd/#20
  • Loading branch information
tioon authored Apr 27, 2024
2 parents 5f97f2f + 5ef6441 commit 0ca1f53
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/script/request_deploy_start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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[@]}"

38 changes: 38 additions & 0 deletions .github/script/request_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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"
apicall_method="GET"
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[@]}"

38 changes: 38 additions & 0 deletions .github/script/request_scenario.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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"
apicall_method="GET"
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[@]}"

38 changes: 38 additions & 0 deletions .github/script/request_stage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/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"
apicall_method="GET"
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[@]}"

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ jobs:
run: |
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp test-package.zip s3://baebae-bucket/test-package --content-type application/zip
- name : Start Deploy Using SourceDeploy
run: |
echo "${{ secrets.NAVER_SOURCE_DEPLOY_START }}" > request_deploy_start.sh
chmod +x request_deploy_start.sh
./request_deploy_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ jobs:
run: |
aws --endpoint-url=https://kr.object.ncloudstorage.com s3 cp deploy-package.zip s3://baebae-bucket/deploy-package --content-type application/zip
- name : Start Deploy Using SourceDeploy
run: |
echo "${{ secrets.NAVER_SOURCE_DEPLOY_START }}" > request_deploy_start.sh
chmod +x request_deploy_start.sh
./request_deploy_start.sh

0 comments on commit 0ca1f53

Please sign in to comment.