Skip to content

Merge pull request #9 from pptik/staging #17

Merge pull request #9 from pptik/staging

Merge pull request #9 from pptik/staging #17

Workflow file for this run

name: πŸš€ CI / CD Actions For React Apps Into Server
on:
push:
branches:
- main
pull_request:
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