github action changes #10
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: Deploy Frontend | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout to repo | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "20" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build React app | |
run: npm run build | |
#Clean up old files | |
- name: Clean up old files | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: "rm -rf /home/${{ secrets.USERNAME }}/app/frontend/*" | |
#Deploy new files | |
- name: Deploy to Server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: "./dist/**" | |
target: /home/${{ secrets.USERNAME }}/app/frontend | |
debug: true | |
- name: Reload Nginx | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
debug: true | |
script: | | |
set -e | |
echo "Reloading nginx..." | |
cd /home/${{ secrets.USERNAME }}/app | |
docker compose exec nginx nginx -s reload | |
echo "Deployment completed successfully🚀🚀🚀" |