AUTOMATICALLY PULL COMMITS ON SERVER
Apr 05, 2024 Copy Link
Stop going to cPanel and pulling your commits manually, use GitHub Actions
, and watch how it does everything on your behalf automatically. So, lemme show you how to configure this feature
Firstly, after you have created your awesome repository, create an `index.html`
file that includes any content then go to the Actions tab
, and follow up on the next steps:
1. Click the set up a workflow yourself
link.
2. Choose an expressive name for your yaml
file (e.g. `pull requests.yaml`
).
3. Copy & Paste the next configuration code.
on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: your-server.domain.com
username: ${{ secrets.USER_NAME }}
password: ${{ secrets.PASSWORD }}
server-dir: /your-folder-path-on-server-that-includes-.git-folder/
The previous configuration creates a job listening for an event. When this event is triggered, GitHub will pull the commits on the server via FTP-Deploy-Action using the given server credentials. Certainly, we will define variables instead of exposing our credentials publicly. So, let's see how we can create the variables in the second step
Secondly, we need to create the variables securely and to do so, walk through the following steps:
1. Click the Settings tab
and scroll down until you hit Secrets and variables,
then expand this list.
2. Click on the Actions
section to uncover the New Repository secret
button.
3. Start creating your credentials in case-sensitive mode, to match the variables that you have defined in the `pull requests.yaml`
.
Finally, go to your server and get a clone from your repository in whatever path on the server, and then if you make any change to it, you will find out that GitHub pulls that update on your server on your behalf.
The path that you defined in `
pull requests.yaml`
must match the path that you have cloned your Repository.