An Interest In:
Web News this Week
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
PHP deployment to SSH server using Github action and bash script
In this tutorial we would lean how to deploy our PHP code to a remote server using github action .
Step 1.
ssh into remote server by
for Windows users use Power shell, while Mac users use Terminal.
yyyy : username
xxxx.xxxx.xxxx : Remote IP address
-p :Reference to a port
ZZZZ: port number
Step 2
In the root directory on your linux server create a bash file and write into by using
touch phpdeploy.sh && vi phpdeploy.sh
Step 3
To start typing on the vi editor type press the "a" key and input the following
echo "Deploying changes..."cd /var/www/htmlDIR="ECOMM"if [ -d "$DIR" ]; then cd DIR echo "Pull update " git pull fielse echo "Clone repo" git clone https://username:[email protected]/username/projectname.gitfi
To exit insert mode on vi editor press escape key followed by shift column and type wq(save and quite).
Step 4
This is our final step, this involves creating our .github/main.yaml file in the root of our project.
name:project nameon: push: branches: mainjobs: build-and-deploy: name: Build and deploy next site runs-on: ubuntu-latest steps: - name: copy file via ssh key uses: appleboy/scp-action@master env: HOST: XXXXXXX PORT: XXXXX USERNAME: XXXXX PASSWORD: XXXXXX command_timeout: 100m script: sh phpdeploy.sh
For every time your code is merger to "main" branch the yaml file above would execute.Thanks for reading.
Original Link: https://dev.to/es404020/php-deployment-to-ssh-server-using-github-action-and-bash-script-58e
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To