Update README.md #144
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 to Apache Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Configure known hosts | |
run: | | |
mkdir -p ~/.ssh | |
touch ~/.ssh/known_hosts | |
ssh-keyscan -t rsa ${{ secrets.IP_ADDRESS }} >> ~/.ssh/known_hosts | |
- name: Update server code | |
run: | | |
if sshpass -p ${{ secrets.SSH_PASSWORD }} ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.IP_ADDRESS }} "cd /var/www/html/academix-learning-system-backend/ && sudo git reset --hard HEAD && sudo git pull origin main && sudo php artisan migrate && sudo composer update"; then | |
echo "SSH connection and code update successful." | |
else | |
echo "Failed to establish SSH connection or update the code." | |
fi |