DEV Community

Kishan B
Kishan B

Posted on • Edited 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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more