fix(ci): replace secret variable with static IP in deploy workflow #17
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 Application | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up SSH | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
cat ~/.ssh/id_rsa | |
- name: Set up PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
extensions: mbstring, bcmath, ctype, fileinfo, json, tokenizer, xml, pdo_mysql | |
- name: Install Composer dependencies | |
run: composer install --no-dev --optimize-autoloader | |
- name: Set up SSH 2 | |
run: | | |
ssh-keyscan -H 207.154.255.72 >> ~/.ssh/known_hosts | |
- name: Test SSH Connection | |
run: | | |
ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa [email protected] echo "SSH connection successful" | |
- name: Deploy using SSH | |
uses: appleboy/[email protected] | |
with: | |
host: 207.154.255.72 | |
username: root | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: 22 | |
script: | | |
cd /var/www/laravel | |
git fetch origin | |
git checkout main | |
git pull origin main | |
composer install --no-dev --optimize-autoloader | |
php artisan migrate --force | |
php artisan config:cache | |
php artisan route:cache | |
php artisan view:cache | |
chown -R www-data:www-data storage bootstrap/cache | |
chmod -R 775 storage bootstrap/cache | |
php artisan queue:restart | |
php artisan cache:clear | |
- name: Notify Deployment Success | |
run: echo "Deployment completed successfully!" |