upload s3 bucket
This commit is contained in:
28
.github/workflows/workflow.yml
vendored
28
.github/workflows/workflow.yml
vendored
@@ -48,28 +48,18 @@ jobs:
|
|||||||
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=safeqr-ec2" --query "Reservations[0].Instances[0].InstanceId" --output text)
|
INSTANCE_ID=$(aws ec2 describe-instances --filters "Name=tag:Name,Values=safeqr-ec2" --query "Reservations[0].Instances[0].InstanceId" --output text)
|
||||||
echo "INSTANCE_ID=$INSTANCE_ID" >> $GITHUB_ENV
|
echo "INSTANCE_ID=$INSTANCE_ID" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Start `nc` on EC2 to Listen and Save File
|
- name: Upload JAR to S3
|
||||||
run: |
|
run: |
|
||||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Start netcat to listen and save file" --parameters 'commands=["sudo nc -l -p 1234 > /home/app-0.0.1-SNAPSHOT.jar"]'
|
aws s3 cp target/app-0.0.1-SNAPSHOT.jar s3://s3-bucket-safeqr/
|
||||||
|
|
||||||
- name: Start SSM Port Forwarding
|
- name: Get Presigned URL
|
||||||
id: start-ssm-port-forwarding
|
id: presigned_url
|
||||||
run: |
|
run: |
|
||||||
aws ssm start-session --target ${{ env.INSTANCE_ID }} --document-name AWS-StartPortForwardingSession --parameters '{"portNumber":["1234"],"localPortNumber":["1234"]}' &
|
URL=$(aws s3 presign s3://s3-bucket-safeqr/app-0.0.1-SNAPSHOT.jar --expires-in 3600)
|
||||||
sleep 10
|
echo "PRESIGNED_URL=$URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Install netcat locally
|
- name: Download and Verify JAR on EC2
|
||||||
run: sudo apt-get install -y netcat
|
|
||||||
|
|
||||||
- name: Send File to EC2
|
|
||||||
run: |
|
run: |
|
||||||
echo "Sending JAR file to EC2 instance..."
|
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Download JAR file" --parameters 'commands=["curl -o /home/ec2-user/app-0.0.1-SNAPSHOT.jar ${{ env.PRESIGNED_URL }}", "ls -l /home/ec2-user/app-0.0.1-SNAPSHOT.jar"]'
|
||||||
nc -w 3 127.0.0.1 1234 < target/app-0.0.1-SNAPSHOT.jar
|
|
||||||
continue-on-error: false
|
|
||||||
|
|
||||||
- name: Verify File on EC2
|
|
||||||
run: |
|
|
||||||
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Verify JAR file" --parameters 'commands=["ls -l /home/app-0.0.1-SNAPSHOT.jar"]'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user