Skip to content

修復 docker 啟動異常 (#86) #42

修復 docker 啟動異常 (#86)

修復 docker 啟動異常 (#86) #42

name: React CD
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Move to workspace
run: |
mv packages/frontend $GITHUB_WORKSPACE
- name: Deploy to Server
uses: easingthemes/ssh-deploy@main
env:
SSH_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
REMOTE_HOST: ${{ secrets.HOST }}
REMOTE_USER: ${{ secrets.USERNAME }}
TARGET: ${{ secrets.TARGET_DIR }}/frontend
- name: Executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
cd /webApp/frontend
sudo docker stop react-container
sudo docker rm react-container
sudo docker rmi react-image
sudo docker build --no-cache -t react-image .
sudo docker run --name react-container -d -p 3001:3001 react-image