upload s3 bucket

This commit is contained in:
heyethereum
2024-06-18 01:04:09 +08:00
parent 07b3c738f2
commit 1283a25a6c

View File

@@ -51,16 +51,19 @@ jobs:
run: |
aws s3 cp target/app-0.0.1-SNAPSHOT.jar s3://s3-bucket-safeqr/
- name: Get Presigned URL
id: presigned_url
- name: Download JAR from S3 to EC2
run: |
URL=$(aws s3 presign s3://s3-bucket-safeqr/app-0.0.1-SNAPSHOT.jar --expires-in 3600)
echo "PRESIGNED_URL=$URL" >> $GITHUB_ENV
- name: Download and Verify JAR on EC2
run: |
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"]'
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Download JAR from S3" --parameters 'commands=[
"aws s3 cp s3://s3-bucket-safeqr/app-0.0.1-SNAPSHOT.jar /home/app-0.0.1-SNAPSHOT.jar",
"ls -l /home/app-0.0.1-SNAPSHOT.jar"
]'
- name: Create and Start Systemd Service
run: |
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Create and start service" --parameters 'commands=["sudo bash -c '\''echo -e \"[Unit]\\nDescription=Spring Boot Application\\nAfter=network.target\\n\\n[Service]\\nUser=ec2-user\\nExecStart=/usr/bin/java -jar /home/ec2-user/app-0.0.1-SNAPSHOT.jar\\nRestart=always\\n\\n[Install]\\nWantedBy=multi-user.target\" > /etc/systemd/system/springboot-app.service'\''", "sudo systemctl daemon-reload", "sudo systemctl enable springboot-app", "sudo systemctl start springboot-app", "sudo systemctl status springboot-app"]'
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Create and start service" --parameters 'commands=[
"sudo bash -c '\''cat <<EOF > /etc/systemd/system/springboot-app.service\n[Unit]\nDescription=Spring Boot Application\nAfter=network.target\n\n[Service]\nUser=ssm-user\nExecStart=/usr/bin/java -jar /home/app-0.0.1-SNAPSHOT.jar\nSuccessExitStatus=143\nRestart=always\nRestartSec=3\n\n[Install]\nWantedBy=multi-user.target\nEOF'\''",
"sudo systemctl daemon-reload",
"sudo systemctl enable springboot-app",
"sudo systemctl start springboot-app",
"sudo systemctl status springboot-app"
]'