-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a drop-in replacement for actions/checkout
- Loading branch information
1 parent
1e1d91e
commit 58debef
Showing
3 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
name: Test the checkout action | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
jobs: | ||
test-checkout: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: tarantool/actions/checkout@nickvolynkin/checkout-action | ||
- name: debug | ||
run: git show HEAD && git status -s && git branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Checkout action | ||
|
||
Reliably checkout a git repository with submodules. | ||
Uses actions/checkout and supports a subset of its input variables: | ||
`token`, `fetch-depth` and `submodules`. All other inputs are used with the | ||
default values. | ||
|
||
This action is intended to be a drop-in replacement for actions/checkout, | ||
improving reliability with submodules and other git repository problems. | ||
|
||
Usage: | ||
|
||
```diff | ||
- name: Checkout code | ||
- uses: actions/checkout@v3 | ||
+ uses: tarantool/actions/checkout@master | ||
# just use the same values for these input variables | ||
with: | ||
fetch-depth: 0 | ||
submodules: 'true' | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
``` | ||
|
||
If a workflow had extra tricks against repository problems, they can now be removed: | ||
|
||
|
||
```diff | ||
- - name: Cleanup workspace | ||
- uses: tarantool/actions/cleanup@master | ||
|
||
- name: Checkout code | ||
- uses: actions/checkout@v3 | ||
+ uses: tarantool/actions/checkout@master | ||
with: | ||
fetch-depth: 0 | ||
submodules: 'true' | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
|
||
- # Work-around for https://github.com/actions/checkout/issues/435 | ||
- - name: Update submodules | ||
- run: | | ||
- pushd tarantool-${{ matrix.tarantool-branch }} | ||
- git submodule update --init --recursive --force | ||
- git fetch origin --prune --progress --recurse-submodules \ | ||
- +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* | ||
- popd | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
name: 'Checkout' | ||
description: > | ||
Reliably checkout a git repository with submodules. | ||
Uses actions/checkout and supports a subset of its input variables: | ||
`token`, `fetch-depth` and `submodules`. All other inputs are used with the | ||
default values. | ||
inputs: | ||
token: | ||
description: > | ||
Personal access token (PAT) used to fetch the repository. | ||
Only required for checking out private repositories. | ||
required: false | ||
default: ${{ github.token }} | ||
fetch-depth: | ||
description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.' | ||
default: 1 | ||
submodules: | ||
description: > | ||
Whether to checkout submodules: `true` to checkout submodules, `recursive` | ||
to recursively checkout submodules, or `false` (default) to only checkout | ||
the main repository. | ||
default: false | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
id: checkout | ||
continue-on-error: true | ||
with: | ||
token: ${{ inputs.token }} | ||
fetch-depth: ${{ inputs.fetch-depth }} | ||
submodules: ${{ inputs.submodules }} | ||
|
||
- name: Cleanup workspace | ||
if: steps.checkout.outcome != 'success' | ||
uses: ./cleanup | ||
|
||
- name: Checkout after cleanup | ||
uses: actions/checkout@v3 | ||
if: steps.checkout.outcome != 'success' | ||
with: | ||
token: ${{ inputs.token }} | ||
fetch-depth: ${{ inputs.fetch-depth }} | ||
submodules: ${{ inputs.submodules }} | ||
|
||
# Work-around for https://github.com/actions/checkout/issues/435 | ||
- name: Update submodules including tags | ||
if: inputs.submodules == 'true' | ||
run: | | ||
pushd tarantool-${{ matrix.tarantool-branch }} | ||
git fetch origin --prune --progress \ | ||
+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* | ||
popd | ||
shell: bash | ||
|
||
- name: Recursively update submodules including tags | ||
if: inputs.submodules == 'recursive' | ||
run: | | ||
pushd tarantool-${{ matrix.tarantool-branch }} | ||
git submodule update --init --recursive --force | ||
git fetch origin --prune --progress --recurse-submodules \ | ||
+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* | ||
popd | ||
shell: bash |