split JAP into chunks

This commit is contained in:
heyethereum
2024-06-17 23:10:17 +08:00
parent fa4d9ddc33
commit 4aeb19a583

View File

@@ -35,9 +35,13 @@ jobs:
- name: Build with Maven - name: Build with Maven
run: mvn -B package --file pom.xml run: mvn -B package --file pom.xml
- name: Split JAR into Chunks - name: Split and Encode JAR into Chunks
run: | run: |
split -b 10M target/app-0.0.1-SNAPSHOT.jar target/chunk_ mkdir -p chunks
split -b 10M target/app-0.0.1-SNAPSHOT.jar chunks/chunk_
for file in chunks/chunk_*; do
base64 $file > ${file}.b64
done
- name: Configure AWS Credentials - name: Configure AWS Credentials
id: configure-aws-credentials id: configure-aws-credentials
@@ -54,8 +58,8 @@ jobs:
- name: Upload Chunks to EC2 - name: Upload Chunks to EC2
run: | run: |
for file in target/chunk_*; do for file in chunks/chunk_*.b64; do
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Upload chunk" --parameters commands="echo \"$(cat $file)\" > /home/ec2-user/$(basename $file)" aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Upload chunk" --parameters commands="echo $(cat $file) | base64 --decode > /home/ec2-user/$(basename ${file%.b64})"
done done
- name: Reassemble Chunks on EC2 - name: Reassemble Chunks on EC2
@@ -64,5 +68,4 @@ jobs:
- name: Verify File on EC2 - name: Verify File on EC2
run: | run: |
aws ssm send-command --instance-ids ${{ env.INSTANCE_ID }} --document-name "AWS-RunShellScript" --comment "Verify JAR file" --parameters 'commands=["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 "Verify JAR file" --parameters 'commands=["ls -l /home/ec2-user/app-0.0.1-SNAPSHOT.jar"]'