Merge pull request #29 from pptik/dev #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π CI / CD Actions For React Apps Into Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: π Deploy to server | |
runs-on: ubuntu-latest | |
steps: | |
- name: π Checkout Code | |
uses: actions/checkout@v3 | |
- name: π Copy file into server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
source: "." | |
target: "/home/pptik-wbs/frontend/web-panic-button112" | |
- name: π§Ή Clean up old images | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
dangling_images=$(sudo docker images -f "dangling=true" -q) | |
if [ -n "$dangling_images" ]; then | |
sudo docker rmi $dangling_images || true | |
fi | |
sudo docker container prune -f | |
- name: π³ Build Docker compose | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_HOST }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
cd /home/pptik-wbs/frontend/web-panic-button112 | |
sudo docker compose up -d --build |