Checking Out Code Using Github Action in Legacy Runner

August 18, 2024   

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

with

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

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.


comments powered by Disqus