forked from uncefact/project-vckit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nam Hoang <[email protected]>
- Loading branch information
1 parent
494139a
commit 770802f
Showing
12 changed files
with
167 additions
and
135 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build and Deploy Agent | ||
|
||
on: | ||
push: | ||
branches: | ||
- demo | ||
|
||
jobs: | ||
install_and_build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write | ||
|
||
env: | ||
CI: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install AWS CLI | ||
run: | | ||
sudo apt-get -q install -y python3-pip | ||
pip3 install awscli --upgrade --user | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_GITHUB_ACTION_ARN }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Remove Explorer | ||
run: rm -rf packages/demo-explorer packages/react-components packages/vckit-oa-renderers | ||
|
||
- name: Compress Agent Server | ||
run: tar -czf agent-server.tar.gz * | ||
|
||
- name: Upload Artifact to S3 | ||
run: aws s3 cp agent-server.tar.gz s3://${{ vars.AGENT_SERVER_AWS_S3_BUCKET_NAME }}/agent-server.tar.gz | ||
|
||
|
||
deploy: | ||
needs: install_and_build | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install AWS CLI | ||
run: | | ||
sudo apt-get -q install -y python3-pip | ||
pip3 install awscli --upgrade --user | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
role-to-assume: ${{ secrets.AWS_ROLE_GITHUB_ACTION_ARN }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Deploy to EC2 | ||
run: aws deploy create-deployment --application-name ${{ vars.AWS_DEPLOY_APP_NAME }} --deployment-group-name ${{ vars.AWS_DEPLOY_GROUP_NAME }} --s3-location bucket=${{ vars.AGENT_SERVER_AWS_S3_BUCKET_NAME }},key=agent-server.tar.gz,bundleType=tgz --ignore-application-stop-failures | ||
|
||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ jobs: | |
node-version: '18' | ||
|
||
- name: Install pnpm | ||
run: npm install -g [email protected].2 | ||
run: npm install -g [email protected].0 | ||
|
||
- name: pnpm version | ||
run: pnpm --version | ||
|
@@ -47,8 +47,14 @@ jobs: | |
echo REACT_APP_DEFAULT_AGENT_ID=${{ vars.REACT_APP_DEFAULT_AGENT_ID }} >> .env | ||
cat .env | ||
- name: Build | ||
run: pnpm build | ||
- name: Build example documents | ||
run: cd packages/example-documents && pnpm build | ||
|
||
- name: Build renderer | ||
run: cd packages/renderer && pnpm build | ||
|
||
- name: Build explorer | ||
run: cd packages/demo-explorer && pnpm build | ||
|
||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v3 | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
version: 0.0 | ||
os: linux | ||
files: | ||
- source: / | ||
destination: /home/ec2-user/agent_server | ||
hooks: | ||
ApplicationStop: | ||
- location: aws/scripts/application_stop.sh | ||
timeout: 300 | ||
runas: root | ||
BeforeInstall: | ||
- location: aws/scripts/before_install.sh | ||
timeout: 300 | ||
runas: root | ||
AfterInstall: | ||
- location: aws/scripts/after_install.sh | ||
timeout: 1200 | ||
runas: root | ||
ApplicationStart: | ||
- location: aws/scripts/application_start.sh | ||
timeout: 300 | ||
runas: root | ||
ValidateService: | ||
- location: aws/scripts/validate_service.sh | ||
timeout: 300 | ||
runas: root |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# Install dependencies | ||
source /home/ec2-user/.bashrc | ||
cd /home/ec2-user/agent_server | ||
pnpm install | ||
pnpm build |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
source /home/ec2-user/.bashrc | ||
cd /home/ec2-user/agent_server | ||
pnpm vckit config | ||
# Start server | ||
pm2 start pnpm -- vckit server |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# Restart codedeploy agent | ||
sudo service codedeploy-agent stop | ||
sudo rm -rf /opt/codedeploy-agent/deployment-root/* | ||
sudo service codedeploy-agent start | ||
|
||
# Stop server | ||
pm2 stop all | ||
|
||
# Delete old source | ||
if [ -d /home/ec2-user/agent_server ]; then | ||
sudo rm -rf /home/ec2-user/agent_server | ||
fi | ||
|
||
sudo mkdir -vp /home/ec2-user/agent_server |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
if git --version; then | ||
echo "git already installed" | ||
else | ||
sudo yum install git -y | ||
fi | ||
|
||
if node --version; then | ||
echo "node already installed" | ||
else | ||
sudo yum install gcc-c++ make -y | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash | ||
. ~/.nvm/nvm.sh | ||
nvm install 16 | ||
npm install -g [email protected] | ||
npm install pm2 -g | ||
fi |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
NUMBER_OF_ATTEMPTS=10 | ||
SLEEP_TIME=3 | ||
|
||
for i in `seq 1 $NUMBER_OF_ATTEMPTS`; | ||
do | ||
HTTP_CODE=`curl --insecure --write-out '%{http_code}' -o /dev/null -m 10 -q -s http://localhost:3332/open-api.json` | ||
if [ "$HTTP_CODE" == "200" ]; then | ||
echo "app server is running." | ||
exit 0 | ||
fi | ||
echo "Attempt to curl endpoint returned HTTP Code $HTTP_CODE. Backing off and retrying." | ||
sleep $SLEEP_TIME | ||
done | ||
echo "Server did not come up after expected time. Failing." | ||
exit 1 |