I am trying to deploy my laravel application to my server using Github actions for build and test and then deploy via ssh.
I have a master repository that I use for development and then I have a production repo that is attached to actions script.
I tried following this tutorial for github actions deployment.
My build works fine but at the time of deployment it is not able to find my deployment script ie server_deploy.sh
here's my main.yml file
name: CD
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.PUSH_TOKEN }}
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: '12.x'
- run: npm install
- run: npm run production
- name: Commit built assets
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -B deploy
git add -f public/
git commit -m "Build front-end assets"
git push -f origin deploy
- name: Deploy to production
uses: appleboy/ssh-action@master
with:
username: ${{ secrets.SSH_USERNAME }}
host: ${{ secrets.SSH_HOST }}
password: ${{ secrets.SSH_PASSWORD }}
script: 'cd /home/admin/web/case4.example.co/public_html/ && ls && sh server_deploy.sh'
and here's my server_deploy.sh
#!/bin/sh
set -e
echo "Deploying application ..."
# Enter maintenance mode
(php artisan down --message 'The app is being (quickly!) updated. Please try again in a minute.') || true
# Update codebase
git fetch origin deploy
git reset --hard origin/deploy
# Install dependencies based on lock file
composer install --no-interaction --prefer-dist --optimize-autoloader
# Exit maintenance mode
php artisan up
echo "Application deployed!"
However, when I execute this workflow, it cannot find the server_deploy.sh file.
I tried ls
to see if even my repo checks out but it doesn't.
Please help.
You didn't setup your server according to the tutorial
Note that the server is always on the deploy branch.
With all this set up, install your Laravel application into
/var/www/html
and checkout thedeploy
branch. If it doesn't exist yet, you can dogit checkout production && git checkout -b deploy
to create it.
You have to run this once on your server and checkout the deploy branch that contains the deploy script server_deploy.sh
You'll need to login first to your server and then upload the server_deploy.sh
to your root folder; eg: /var/www/html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.