Skip to content

Commit e8dcae2

Browse files
authored
ci: update repo url in deployment script (#877)
* ci: update deployment init scripts * ci: add sui cli tool
1 parent f149a26 commit e8dcae2

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

.github/deployer/init_script.sh

+44-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ exec 1>/tmp/user_data_log.out 2>&1
66
# Below variable is resolved during the rendering of the Terraform template file.
77
SSH_PUBKEY="SSH_PUBKEY_HERE"
88
CIPHER_TEXT="CIPHER_TEXT_HERE"
9+
export GITHUB_ACCESS_TOKEN="GITHUB_TOKEN_HERE"
10+
export CI_USER="CI_USER_HERE"
911
DEPLOY_SCRIPT_BRANCH="DEPLOY_SCRIPT_BRANCH_HERE" # Deployment repo: https://github.com/izyak/icon-ibc.git
1012
KMS_ID="KMS_ID_HERE"
1113
DEPLOYR_HOME="/home/deployr"
@@ -37,7 +39,7 @@ sysctl -p
3739
#Update OS Packages
3840
apt-get update
3941
apt-get upgrade -y
40-
42+
apt-get install expect -y
4143

4244
cat << 'EOF' >> /etc/profile
4345
# Setup ENV and command history loging
@@ -73,11 +75,39 @@ mkdir -p /opt/deployer/{bin,root}
7375
mkdir -p /opt/deployer/root/{keystore,keyutils}
7476

7577
# Clone repo
76-
cd /opt/deployer/root/ && git clone https://github.com/izyak/icon-ibc.git
77-
cd icon-ibc
78+
cat << 'EOF' > clone.expect
79+
#!/usr/bin/expect -f
80+
81+
# Set the GitHub credentials from arguments
82+
set timeout -1
83+
set username [lindex $argv 0]
84+
set token [lindex $argv 1]
85+
set repo_url "https://github.com/icon-project/devnet.git"
86+
set target_dir "/opt/deployer/root/ibc-devops"
87+
88+
# Clone the repository
89+
spawn git clone $repo_url $target_dir
90+
expect "Username for 'https://github.com':"
91+
send "$username\r"
92+
expect "Password for 'https://$username@github.com':"
93+
send "$token\r"
94+
expect eof
95+
EOF
96+
97+
chmod +x clone.expect
98+
git config --global credential.helper "cache --timeout=604800"
99+
./clone.expect "$CI_USER" "$GITHUB_ACCESS_TOKEN"
100+
CI_USER_ESCAPED="$${CI_USER//@/%40}"
101+
echo -e "[credential]\n\thelper = store" >> ~/.gitconfig
102+
echo "https://$${CI_USER_ESCAPED}.com:$${GITHUB_ACCESS_TOKEN}@gihub.com" > ~/.git-credentials
103+
104+
cd /opt/deployer/root/ibc-devops
78105
git checkout $${DEPLOY_SCRIPT_BRANCH}
79106
cd ..
80-
cp -r icon-ibc/deployer/* /opt/deployer
107+
mv /ibc-devops /opt/deployer/root
108+
cd /opt/deployer/root/
109+
cp -r ibc-devops/Deployments/relayer/deployer/* /opt/deployer
110+
81111

82112
# Create user & configure ssh access
83113
useradd -m -d $${DEPLOYR_HOME} -s /bin/bash deployr
@@ -107,7 +137,7 @@ go install github.com/icon-project/goloop/cmd/goloop@latest
107137
# Install archway
108138
wget -q https://github.com/archway-network/archway/releases/download/v$${ARCHWAY_VERS}/archway_$${ARCHWAY_VERS}_linux_amd64.zip
109139
unzip archway_$${ARCHWAY_VERS}_linux_amd64.zip
110-
sudo archwayd /usr/local/bin
140+
sudo cp archwayd /usr/local/bin
111141

112142
# Install injectived
113143
wget -q https://github.com/InjectiveLabs/injective-chain-releases/releases/download/v$${INJECTIVE_VERS}/linux-amd64.zip
@@ -122,6 +152,15 @@ wget -q https://github.com/neutron-org/neutron/releases/download/v$${NEUTRON_VER
122152
sudo cp neutrond-linux-amd64 /usr/local/bin/neutrond
123153
sudo chmod +x /usr/local/bin/neutrond
124154

155+
# Install sui
156+
wget -q https://github.com/MystenLabs/sui/releases/download/$${SUI_VERS}/sui-$${SUI_VERS}-ubuntu-x86_64.tgz
157+
sudo tar xf sui-$${SUI_VERS}-ubuntu-x86_64.tgz -C /usr/local/bin
158+
sudo chmod +x /usr/local/bin/sui
159+
160+
# Install Dasel
161+
sudo wget -qO /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64
162+
sudo chmod a+x /usr/local/bin/dasel
163+
125164
# Install boto3, yq, and jq
126165
apt-get install python3-pip -y
127166
pip3 install boto3

.github/workflows/run-deployer.yml

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
TF_VAR_subnet_id: "${{ secrets.SUBNET_ID }}"
5757
TF_VAR_vpc_security_group_ids: "${{ secrets.SECURITY_GROUP_ID }}"
5858
kms_id: "${{ secrets.KMS_ID }}"
59+
ci_user: "${{ secrets.CI_USER }}"
60+
repo_token: "${{ secrets.DEVNET_REPO_ACCESS }}"
5961
deployr_ssh_pub_key: "${{ github.event.inputs.deployr_ssh_pub_key }}"
6062
deploy_script_branch: "${{ github.event.inputs.deploy_script_branch }}"
6163

@@ -68,6 +70,8 @@ jobs:
6870
sed -i "s|CIPHER_TEXT_HERE|$cipher_text|g" init_script.sh
6971
sed -i "s|DEPLOY_SCRIPT_BRANCH_HERE|$deploy_script_branch|g" init_script.sh
7072
sed -i "s|KMS_ID_HERE|$kms_id|g" init_script.sh
73+
sed -i "s|GITHUB_TOKEN_HERE|$repo_token|g" init_script.sh
74+
sed -i "s|CI_USER_HERE|$ci_user|g" init_script.sh
7175
terraform init
7276
terraform validate
7377
terraform plan

0 commit comments

Comments
 (0)