DEV Community

Kishan B
Kishan B

Posted on • Updated on • Originally published at kishaningithub.github.io

Checking out code using github action in legacy runner

Problem

Performing a simple git checkout using official checkout action fails in a legacy self hosted runner running amazon linux 2 because newer versions of nodejs(>= 20) requires a newer version of GLIBC which is not available in these operating systems.

Solution

Use bash to perform the checkout in the action code i.e

replace the line

- uses: actions/checkout@v3
Enter fullscreen mode Exit fullscreen mode

with

- name: Checkout
  run: |
    git clone --depth 1 -b "${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}" "https://github.com/${GITHUB_REPOSITORY}.git" .
Enter fullscreen mode Exit fullscreen mode

Note

  • --depth 1 performs a shallow-clone there by increasing your performance as we don't need to pull the entire commit history for every pipeline run.
  • ${GITHUB_HEAD_REF:-$GITHUB_REF_NAME} doing this to ensure we always get the name of the branch which triggered the pipelines. This way of doing it makes it trigger agnostic i.e. both push and pull request trigger will work as intended.
  • . The dot at the end ensures that the checkout happens in the current directory which is the workspace.

Top comments (0)