GitHub Action
Checkout From Tag
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.
- 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.
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."
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.
None yet.
PR's welcome...