Skip to content

Commit

Permalink
Fix: 스크립트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
mingeun.kim committed Oct 19, 2024
1 parent 7b3003c commit db46f75
Showing 1 changed file with 31 additions and 20 deletions.
51 changes: 31 additions & 20 deletions .github/workflows/ncp-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,36 @@ jobs:
needs: build_and_push
runs-on: ubuntu-latest
steps:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.NCP_DEV_SSH_KEY }}
known_hosts: ${{ secrets.NCP_DEV_KNOWN_HOSTS }}

- name: Install sshpass
run: sudo apt-get install sshpass

- name: Connect SSH and Deploy
env:
SSH_PASSWORD: ${{ secrets.NCP_DEV_PASSWORD }}
- name: Setting NCP CLI & Credentials
run: |
sshpass -p "$SSH_PASSWORD" ssh -tt -o StrictHostKeyChecking=no root@${{ secrets.NCP_DEV_HOST }} << EOF
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/${{ env.PROJECT_NAME }}:latest
docker stop ${{ env.PROJECT_NAME }} || true
docker rm ${{ env.PROJECT_NAME }} || true
docker run -d --name ${{ env.PROJECT_NAME }} -p 8080:8080 \
-e SPRING_PROFILES_ACTIVE=prod \
${{ secrets.NCP_CONTAINER_REGISTRY }}/${{ env.PROJECT_NAME }}:latest
cd ~
wget https://www.ncloud.com/api/support/download/5/65
unzip 65
mkdir ~/.ncloud
echo -e "[DEFAULT]\nncloud_access_key_id = ${{ secrets.NCP_ACCESS_KEY }}\nncloud_secret_access_key = ${{ secrets.NCP_SECRET_KEY }}\nncloud_api_url = https://ncloud.apigw.ntruss.com" >> ~/.ncloud/configure
- name: deploy file
uses: wlixcc/[email protected]
with:
username: 'root'
server: ${{ secrets.NCP_DEV_HOST }}
password: ${{ secrets.NCP_DEV_PASSWORD }}
local_path: './docker-compose.yml'
remote_path: '/root'
sftpArgs: '-o ConnectTimeout=5'

- name: Connect SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.NCP_DEV_HOST }}
username: root
password: ${{ secrets.NCP_DEV_PASSWORD }}
port: 22
script: |
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/nextjs-server
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker compose up -d
docker image prune -f
EOF

0 comments on commit db46f75

Please sign in to comment.