Skip to content

Commit 2bb4cad

Browse files
committed
ci: fixed s3 upload error, added aws cli install for s3 download
1 parent 30d3e87 commit 2bb4cad

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

.github/workflows/ci-cd-aws.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ jobs:
2525
# Step 4
2626
- name: Compress
2727
run: |
28-
tar -zcvf dist.tar.gz frontend/forum-app/dist
28+
cd frontend/forum-app
29+
tar -zcvf dist.tar.gz dist
2930
# Step 5
3031
- name: Configure AWS Credentials
3132
uses: aws-actions/configure-aws-credentials@v1
@@ -36,9 +37,8 @@ jobs:
3637
# Step 6
3738
- name: Upload dist archive to S3 bucket
3839
run: |
39-
pwd
40-
aws s3 sync dist.tar.gz s3://${{ secrets.AWS_S3_BUCKET_NAME }} --delete
41-
cd ../..
40+
cd frontend/forum-app
41+
aws s3 cp dist.tar.gz s3://${{ secrets.AWS_S3_BUCKET_NAME }}
4242
4343
# Step 7
4444
- name: Set up Go

scripts/before_install.sh

+20
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,23 @@ if [ -d /opt/simple-reddit ]; then
55
fi
66

77
mkdir -vp /opt/simple-reddit
8+
9+
# Install AWS CLI
10+
cd /opt/simple-reddit
11+
12+
WHICH_AWS=$(which aws)
13+
echo $WHICH_AWS
14+
if [ -z $WHICH_AWS ]; then
15+
echo "Installing aws cli..."
16+
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
17+
unzip awscliv2.zip
18+
sudo ./aws/install
19+
source /home/ubuntu/aws/credentials.sh
20+
source /home/ubuntu/aws/config.sh
21+
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
22+
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
23+
aws configure set default.region $AWS_DEFAULT_REGION
24+
else
25+
echo "aws cli already installed"
26+
fi
27+

0 commit comments

Comments
 (0)