Search code examples
checkoutgithub-actionsgithub-actions-self-hosted-runners

GitHub Action checkout fails when unzipping with self hosted agent


I'm setting up a CI/CD pipeline using GitHub Actions and a self-hosted agent installed on a windows 2019 server.

The problem I'm facing is that the action actions/checkout@v2 fails to check out the repo and fully unzip it. When I say "fully unzip" I mean that there are some files inthe target folder it managed to unzip before stalling.

From the log:

Run actions/checkout@v2
Syncing repository: Syd/ExternWebb
Getting Git version info
Deleting the contents of 'C:\actions-runner\_work\ExternWebb\ExternWebb'
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313.tar.gz', 'C:\actions-runner\_work\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313')"
Exception calling "ExtractToDirectory" with "2" argument(s): "Could not find a part of the path 'C:\actions-runner\_wor
k\ExternWebb\ExternWebb\b3193a49-e100-4cbd-81c9-6bd23ff47313\Syd-ExternWebb-77d0427f54bc3e4d6694
f0719ca9fe3ab3be3706\ExternWebb.Library\Custom\Plugins\DomainRedirectModule\DomainRedirectConfigurationCollection
.cs'."
At line:1 char:111
+ ... catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\a ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : DirectoryNotFoundException
 
Error: The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1

I've tried running the same action on a locally self-hosted agent without any trouble.

A reddit post suggests that the error can be mitigated by fetching the repo via Git instead, pointing to this clue in the log:

The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH

I tried to install Git v.2.30 and added it to the PATH as instructed above, but for some reason the action still downloads the repo via the GIT API. I don't know if a restart of the server is required but the git commands are available in Powershell.

I'm guessing that's why the locally self-hosted agent (which has access to GIT) can check out the repo, but the agent running on the server can't.

This is the workflow yml-file:

name: Build Stage

on:
  push:
    branches: [ develop ]
  pull_request:
    branches: [ develop ]

jobs:
  build:
    runs-on: [self-hosted, stage]
    env:
      CONFIG: Stage
      BUILD_FOLDER: _build
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      
    steps:
    - name: Checking out source code
      uses: actions/checkout@v2

Any insights are appretiated.


Solution

  • Ensure that you stop and restart the GitHub Actions Runner service after installing Git. That did it for me.