I am trying to pull change from origin using GitHub Actions.
I have a workflow in yml file set up like below. I have a runner (self-hosted) set up on my apache server so that it will run git pull
when code is pushed to xxx
branch. I confirmed that it was running and connected to GitHub. When I commit change and merge it to xxx
branch, workflow runs without error. However, git pull
says 'Already up to date' even though there is change.
How do I properly pull using GitHub actions?
# This is a basic workflow to help you get started with Actions
name: Test
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ xxx ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# pull the change for deploy-test
- name: Pull the change from server
env:
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
run: |
git pull origin xxx --rebase
echo $USERNAME
echo $TOKEN
When I run git pull
manually in the server, it pulls the change like below.
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 18 (delta 9), reused 10 (delta 4), pack-reused 0
Unpacking objects: 100% (18/18), 2.87 KiB | 978.00 KiB/s, done.
From https://github.com/my-username/my-directory
* branch xxx -> FETCH_HEAD
myhash..myhash xxx -> origin/xxx
Updating a22125c..a2981f2
Fast-forward
.github/workflows/test.yml | 10 ++++++++++
1 file changed, 10 insertions(+)
But github actions says this
git pull origin xxx --rebase
https://github.com/***/my-directory
* branch xxx -> FETCH_HEAD
Already up to date.
***
***
- uses: actions/checkout@v2
is checking out repository in its latest stage for you - so if youpull
just after that it will correctly confirm that everything is up to date and that there's nothing more to pull.