Skip to content

Commit 6838c04

Browse files
author
kiran-garre
committed
Add docs-specific setup script
1 parent b842e74 commit 6838c04

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

.github/workflows/docs-generator.yaml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@ jobs:
3333
with:
3434
role-to-assume: ${{ secrets.AWS_TB_ROLE }}
3535
aws-region: us-east-1
36-
37-
- name: Run setup_amazon_q.sh from terminal-bench
38-
run: |
39-
cd terminal-bench-test
40-
chmod +x setup_amazon_q.sh
41-
sudo bash setup_amazon_q.sh
4236

4337
- name: Make scripts executable
4438
run: |
39+
chmod +x dogs-generation/setup_amazon_q.sh
4540
chmod +x docs-generation/create-docs-pr.sh
4641
chmod +x docs-generation/read-pr.sh
4742
chmod +x docs-generation/update-docs.sh
4843
44+
- name: Run setup script
45+
run: bash docs-generation/setup_amazon_q.sh
46+
4947
- name: Generate PR contents file
5048
run: bash docs-generation/read-pr.sh ${{ inputs.pr_number }}
5149

docs-generation/setup_amazon_q.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
set -e
3+
# if git hash empty then set to latest auto
4+
sudo apt-get update
5+
sudo apt-get install -y curl wget unzip jq
6+
7+
# Create AWS credentials from environment variables
8+
mkdir -p ~/.aws
9+
cat > ~/.aws/credentials << EOF
10+
[default]
11+
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
12+
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
13+
aws_session_token = ${AWS_SESSION_TOKEN}
14+
EOF
15+
chmod 600 ~/.aws/credentials
16+
17+
cat > ~/.aws/config << EOF
18+
[default]
19+
region = us-east-1
20+
EOF
21+
chmod 600 ~/.aws/config
22+
23+
# Assume role and capture temporary credentials --> needed for s3 bucket access for build
24+
echo "Assuming AWS s3 role"
25+
TEMP_CREDENTIALS=$(aws sts assume-role --role-arn ${CHAT_DOWNLOAD_ROLE_ARN} --role-session-name S3AccessSession 2>/dev/null || echo '{}')
26+
QCHAT_ACCESSKEY=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.AccessKeyId')
27+
Q_SECRET_ACCESS_KEY=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.SecretAccessKey')
28+
Q_SESSION_TOKEN=$(echo $TEMP_CREDENTIALS | jq -r '.Credentials.SessionToken')
29+
30+
# Download specific build from S3 based on commit hash
31+
echo "Downloading Amazon Q CLI build from S3..."
32+
S3_PREFIX="main/${GIT_HASH}/x86_64-unknown-linux-musl"
33+
echo "Downloading qchat.zip from s3://.../${S3_PREFIX}/qchat.zip"
34+
35+
# Try download, if hash is invalid we fail.
36+
AWS_ACCESS_KEY_ID="$QCHAT_ACCESSKEY" AWS_SECRET_ACCESS_KEY="$Q_SECRET_ACCESS_KEY" AWS_SESSION_TOKEN="$Q_SESSION_TOKEN" \
37+
aws s3 cp s3://${CHAT_BUILD_BUCKET_NAME}/${S3_PREFIX}/qchat.zip ./qchat.zip --region us-east-1
38+
39+
# Handle the zip file, copy the qchat executable to /usr/local/bin + symlink from old code
40+
echo "Extracting qchat.zip..."
41+
unzip -q qchat.zip
42+
43+
# move it to /usr/local/bin/qchat for path as qchat may not work otherwise
44+
if cp qchat /usr/local/bin/ && chmod +x /usr/local/bin/qchat; then
45+
ln -sf /usr/local/bin/qchat /usr/local/bin/q
46+
echo "qchat installed successfully"
47+
else
48+
echo "ERROR: Failed to install qchat"
49+
exit 1
50+
fi
51+
52+
echo "Cleaning q zip"
53+
rm -f qchat.zip
54+
rm -rf qchat

0 commit comments

Comments
 (0)