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
c49af42
commit 494139a
Showing
4 changed files
with
132 additions
and
0 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,114 @@ | ||
name: Deploy to S3 | ||
|
||
on: | ||
push: | ||
branches: | ||
- demo | ||
|
||
jobs: | ||
install_and_build: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
CI: false | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cache dependencies | ||
id: cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.pnpm-store | ||
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install pnpm | ||
run: npm install -g [email protected] | ||
|
||
- name: pnpm version | ||
run: pnpm --version | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: 'Create env file' | ||
run: | | ||
touch .env | ||
echo REACT_APP_ENCRYPTED_ENDPOINT=${{ vars.REACT_APP_ENCRYPTED_ENDPOINT}} >> .env | ||
echo REACT_APP_QRCODE_VERIFY_ENDPOINT=${{ vars.REACT_APP_QRCODE_VERIFY_ENDPOINT }} >> .env | ||
echo REACT_APP_SCHEMA_URL=${{ vars.REACT_APP_SCHEMA_URL }} >> .env | ||
echo REACT_APP_REMOTE_AGENT_API_KEY=${{ vars.REACT_APP_REMOTE_AGENT_API_KEY }} >> .env | ||
echo REACT_APP_DEFAULT_AGENT_ID=${{ vars.REACT_APP_DEFAULT_AGENT_ID }} >> .env | ||
cat .env | ||
- name: Build | ||
run: pnpm build | ||
|
||
- name: Archive artifacts for Agent Explorer | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: explorer | ||
path: packages/demo-explorer/build/explorer | ||
|
||
- name: Remove Explorer and compress Agent Server | ||
run: rm -rf packages/demo-explorer/build/explorer packages/react-components && tar -czf agent-server.tar.gz * | ||
|
||
- name: Archive artifacts for Agent Server | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: agent-server | ||
path: agent-server.tar.gz | ||
|
||
deploy_to_s3: | ||
needs: install_and_build | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download artifacts for Agent Explorer | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: explorer | ||
path: packages/demo-explorer/build/explorer | ||
|
||
- name: Download artifacts for Agent Server | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: agent-server | ||
path: agent-server.tar.gz | ||
|
||
- 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 S3 for Agent Explorer | ||
run: aws s3 sync packages/demo-explorer/build/explorer/ s3://${{ vars.EXPLORER_AWS_S3_BUCKET_NAME }} --delete | ||
|
||
- name: Invalidate CloudFront | ||
run: | | ||
DISTRIBUTION_ID=${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_ID }} | ||
INVALIDATION_PATH="/*" | ||
# Create a new CloudFront invalidation | ||
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths $INVALIDATION_PATH | ||
- name: Deploy to S3 for Agent Server | ||
run: aws s3 cp agent-server.tar.gz s3://${{ vars.AGENT_SERVER_AWS_S3_BUCKET_NAME }}/agent-server.tar.gz |
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,7 @@ | ||
#!/bin/bash | ||
# Delete old source | ||
if [ -d /usr/local/agent_server ]; then | ||
rm -rf /usr/local/agent_server | ||
fi | ||
|
||
mkdir -vp /usr/local/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,6 @@ | ||
#!/bin/bash | ||
# Install dependencies | ||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash | ||
. ~/.nvm/nvm.sh | ||
nvm install 16 | ||
npm install -g [email protected] |
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,5 @@ | ||
#!/bin/bash | ||
# Start server | ||
cd /usr/local/agent_server | ||
pnpm vckit config | ||
pnpm vckit server |