Skip to content

Commit

Permalink
chore: 배포 스크립트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kariskan committed Aug 22, 2024
1 parent 32cc51f commit 6dc1e5f
Showing 1 changed file with 17 additions and 41 deletions.
58 changes: 17 additions & 41 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,28 @@ jobs:
- name: Build with Gradle
run: ./gradlew clean build -x test

- name: Archive WAR file
uses: actions/upload-artifact@v2
with:
name: application-war
path: build/libs/*.war

deploy:
needs: build
runs-on: ubuntu-latest

steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: application-war
path: ./build/libs

- name: Create SSH key file
env:
SCP_KEY: ${{ secrets.SCP_KEY }}
SCP_KEY: ${{ secrets.KEY }}
run: |
echo "${{ secrets.SCP_KEY }}" > scp_key.pem
echo "${{ secrets.KEY }}" > scp_key.pem
chmod 600 scp_key.pem
- name: Verify SSH key file
run: ls -la scp_key.pem

- name: Copy WAR to EC2
- name: Copy JAR to EC2
env:
SCP_USER: ${{ secrets.SCP_USER }}
SCP_HOST: ${{ secrets.SCP_HOST }}
SCP_PATH: ${{ secrets.SCP_PATH }}
SCP_USER: ${{ secrets.USER }}
SCP_HOST: ${{ secrets.HOST }}
SCP_PATH: ${{ secrets.PATH }}
run: |
scp -v -o StrictHostKeyChecking=no -i scp_key.pem ./build/libs/*.war $SCP_USER@$SCP_HOST:/home/kariskan/ROOT.war
scp -v -o StrictHostKeyChecking=no -i scp_key.pem ./build/libs/*.jar $SCP_USER@$SCP_HOST:$SCP_PATH
- name: Deploy to Tomcat on EC2
env:
SSH_KEY: ${{ secrets.SCP_KEY }}
SSH_USER: ${{ secrets.SCP_USER }}
SSH_HOST: ${{ secrets.SCP_HOST }}
run: |
echo "${{ secrets.SCP_KEY }}" > ssh_key.pem
chmod 600 ssh_key.pem
ssh -o StrictHostKeyChecking=no -i ssh_key.pem $SSH_USER@$SSH_HOST << EOF
sudo su
cd /home/kariskan
chmod +x deploy.sh
./deploy.sh
EOF
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.KEY }}
script: |
cd ${{ secrets.PATH }}
nohup java -jar *.jar > app.log 2>&1 &
EOF

0 comments on commit 6dc1e5f

Please sign in to comment.