Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,26 @@ jobs:
env:
CI: false
run: cd Frontend && npm run build # This makes sure the build succeeds before running it on the production server

# Compress the build folder
- name: Archive build folder
run: tar -czf build.tar.gz build/

- name: Install SSH Keys
- name: Install SSH Key and Configure Access
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts

# Transfer the build to the server
- name: Upload build to server
run: |
scp -i ~/.ssh/id_rsa build.tar.gz ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.WORK_DIR }}/Frontend

- name: Connect to server and pull
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout development && git pull origin development && cd /var/www/SpeedCart/Frontend && ./build.sh"
- name: Cleanup
run: rm -rf ~/.ssh
# Deploy on the server
- name: Deploy build on server
run: |
ssh -i ~/.ssh/id_rsa ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
cd ${{ secrets.WORK_DIR }}/Frontend
tar -xzf build.tar.gz
rm -f build.tar.gz