Unlike other clone/checkout actions, this action automatically detects the depth of a specified tag or commit hash, and clones/deepens to that depth as necessary.
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 encountered 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 its potential userbase and the associated cost(s) became well worth mitigating.
That said, there's only so much you can do if your .pack file is ~4GB, like like that of torvals/linux. At this point you're still going to wait at least 20m for the bare repository to clone before the depth of the tag can even be determined...
Future Enhancmenet: Adjust the bare directory to be cached with actions/cache. Note to self: Requires 'git fetch <repo_url>' from within dir to update.
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. You must know the depth before specifying it. This is the value offered by this action.
The default behavior of this action is similar to that of 'actions/checkout', except that this action will automatically detect the last semver tag and clone from there to 'origin/HEAD'.
This behavior can be overridden with the following options.
- tag: [string] (Optional)
- The tag or commit hash to clone from.
When NOT supplied this action attempts to detect the last semver tag for the repo.
Default: Null - repo: [string] (Optional)
- The repository to clone.
Specify to clone a different repository.
If cloning a private repo, use ssh url.
Default: The user action repository. - ssh-token: [string] (Optional/Required)
- The deploy/machine token for a private repository.
Required if cloning a 3rd party private repo.
WARN: Supply as a secret.
Default: Null - dir: [string] (Optional/Required)
- The directory into which to clone the repository.
When supplied, the target dir is '$GITHUB_WORKSPACE/$dir'.
The directory must either not exist, or be empty.
Required if cloning a different repo.
Default: $GITHUB_WORKSPACE - output-depth-only: [bool] (Optional)
- Output the detected depth without cloning/deepening.
Default: false
- depth: [string]
- The depth of the tag/commit.
This is a valid workflow utilizing this action.
name: Validate Checkout From Tag
on:
workflow_dispatch:
jobs:
use-action:
name: Checkout From Tag
runs-on: ubuntu-latest
steps:
- name: Checkout github-actions-gitops-autover to the depth of tag 0.1.6
uses: AlexAtkinson/github-action-checkout-from-tag@latest
id: checkout
with:
repo: https://github.com/AlexAtkinson/github-action-gitops-autover.git
tag: 0.1.6
dir: foo_bar
- name: Verify Checkout
run: |
cd foo_bar
echo "DEPTH: ${{ steps.checkout.outputs.depth }}"
git log --tags --pretty=oneline --decorate=full
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...