I have a repo in GitHub with 2 branches (dev
& master
) and an app on a local apache server hosted in my house (the server has a public ip). Currently, whenever I make changes to dev
, I push the code, make a pull request, merge the change to master
and do git pull
on the apache server after ssh into it.
What I want to do is to set up an automatic workflow using GitHub Actions so that the server automatically does git pull
to pull the change from github whenever there is a change. I set up a workflow in yml file and self-hosted runner in the local apache server.
However, I haven't figured it out how to structure yml file. I have copied my yml file below. This yml file returns 'Already up to date' even though there is a change in the remote branch.
I found a couple of articles like this (Automatically pull from remote using GitHub Actions) in stackoverflow and it uses ssh and and also doesn't use self-hosted runner. I am confused whether i should use self-hosted or not. My thinking was since it is a local server, I have to make my server listen to the change and pull the code from github.
Can somebody help me out on this? I highly appreciate the help.
name: Test
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Pull the change from server
env:
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
run: |
git pull origin master --rebase
echo $USERNAME
echo $TOKEN