gitgithub-actionsgit-pullgithub-actions-self-hosted-runners

Using git pull within run in github actions main.yml


I am trying to update a local server running some non-production versions of some of my company's sites to update whenever the main repository merges a pull request. However, the action stalls out when the action hits the git pul ... line. The logs do not provide any information, the process seemingly halts. I can run the same commands in the command prompt. Any advice is appreciated.

main.yml

name: CI
    
    on:
       
      push:
        branches: [ master ]
    
       
      workflow_dispatch:
    
     
    jobs:
       
      deployment:
         
        runs-on: self-hosted
    
         
        steps:
           
          - uses: actions/checkout@v2
    
           
          - name: Test
            shell: cmd
            run: actions.cmd

actions.cmd

cd path\to\stuff
git pull remoteName master

Update, ran into some weird caching issues but was able to clean up a little and got some error messages:

nothing to commit, working tree clean
fatal: 'github' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
success
Error: Process completed with exit code 1.

github is the name of the remote. Again, I can run these scripts normally, but maybe the workflow needs some additional authentication?


Solution

  • Turns out it was an authentication issue. Unfortunately, debugging when actions are being executed on the runner (even when self-hosted) is very frustrating. If anyone knows a better way please feel free to update me.

    Basically the runner did not have the same access rights as the server that was hosting the runner, so I just had to add some authentication steps to the scripts. I thought it would since I already configured the server to successfully run the same commands manually, but this does seem like a good security measure.