Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
settings

GitHub Action

Checkout From Tag

0.0.4 Pre-release

Checkout From Tag

settings

Checkout From Tag

Shallow clones a repo to the depth of the specified tag (or commit hash). Depth is auto-detected.

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Checkout From Tag

uses: AlexAtkinson/[email protected]

Learn more about this action in AlexAtkinson/github-action-checkout-from-tag

Choose a version

Introduction

version license language repo size HitCount Count of Action Users

Unlike other clone/checkout actions, this action automatically detects the depth of a specified tag or commit hash, and clones the specified repo from that depth.

While the shallow clone is often the answer when handling large repos with a lot of history, there are often times when it would be beneficial to be able to clone from 'origin/HEAD' back to a specific tag or commit hash.
Such scenarios have been countered several times through the years as the bones behind the GitOps Automatic Versioning Action were hardening. With the release of that action, the scope of this impediment across it's potential userbase and it's associated cost(s) became well worth mitigating.

NOTE: The GitOps Automatic Versioning action will receive this update in a future release (post 0.1.7).

No, there is no git option to clone a repo after, or between specified commits.

Usage

Inputs

tag: [string] (Required)
The tag or commit hash to clone to.
repo: [string] (Optional)
The repository to clone.
Example: '[email protected]:AlexAtkinson/github-action-checkout-from-tag.git'
Default: The user action repository.
dir: [string] (Optional)
The directory into which to clone the repository.
Default: The name of the repository.

Example GH Action Workflow

This is a valid workflow utilizing this action.

name: checkout-from-tag

on:
  workflow_dispatch:

jobs:
  use-action:
    name: Checkout From Tag
    runs-on: ubuntu-latest
    steps:
    - uses: AlexAtkinson/github-action-checkout-from-tag@latest
      with:
        repo: github-action-gitops-autover
        tag: 0.1.6
        dir: /tmp/foo_bar
    - name: Verify Checkout
      run: |
        cd /tmp/foo_bar
        git log --pretty=oneline
        echo -e "\n\nThere are several versions prior to 0.1.6, so as long as the log ends there, this action has executed successfully."

Code Logic

For those interested, here's some pseudo code:

1. Clone only the administrative files to get access to the full git log.
2. Count the commits between the specified tag/commit and origin/HEAD to determine the depth.
3. Clone the repo to the detected depth.

[Known|Non]-Issues

None yet.

Future Enhancements

PR's welcome...