|
| 1 | +--- |
| 2 | +name: 'Checkout' |
| 3 | +description: > |
| 4 | + Reliably checkout a git repository with submodules. |
| 5 | + Uses actions/checkout and supports a subset of its input variables: |
| 6 | + `token`, `fetch-depth` and `submodules`. All other inputs are used with the |
| 7 | + default values. |
| 8 | +inputs: |
| 9 | + token: |
| 10 | + description: > |
| 11 | + Personal access token (PAT) used to fetch the repository. |
| 12 | + Only required for checking out private repositories. |
| 13 | + required: false |
| 14 | + default: ${{ github.token }} |
| 15 | + fetch-depth: |
| 16 | + description: 'Number of commits to fetch. 0 indicates all history for all branches and tags.' |
| 17 | + default: 1 |
| 18 | + submodules: |
| 19 | + description: > |
| 20 | + Whether to checkout submodules: `true` to checkout submodules, `recursive` |
| 21 | + to recursively checkout submodules, or `false` (default) to only checkout |
| 22 | + the main repository. |
| 23 | + default: false |
| 24 | + |
| 25 | +runs: |
| 26 | + using: 'composite' |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + id: checkout |
| 31 | + continue-on-error: true |
| 32 | + with: |
| 33 | + token: ${{ inputs.token }} |
| 34 | + fetch-depth: ${{ inputs.fetch-depth }} |
| 35 | + submodules: ${{ inputs.submodules }} |
| 36 | + |
| 37 | + - name: Cleanup workspace |
| 38 | + if: steps.checkout.outcome != 'success' |
| 39 | + uses: ./cleanup |
| 40 | + |
| 41 | + - name: Checkout after cleanup |
| 42 | + uses: actions/checkout@v3 |
| 43 | + if: steps.checkout.outcome != 'success' |
| 44 | + with: |
| 45 | + token: ${{ inputs.token }} |
| 46 | + fetch-depth: ${{ inputs.fetch-depth }} |
| 47 | + submodules: ${{ inputs.submodules }} |
| 48 | + |
| 49 | + # Work-around for https://github.com/actions/checkout/issues/435 |
| 50 | + - name: Update submodules including tags |
| 51 | + if: inputs.submodules == 'true' |
| 52 | + run: | |
| 53 | + pushd tarantool-${{ matrix.tarantool-branch }} |
| 54 | + git fetch origin --prune --progress \ |
| 55 | + +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* |
| 56 | + popd |
| 57 | + shell: bash |
| 58 | + |
| 59 | + - name: Recursively update submodules including tags |
| 60 | + if: inputs.submodules == 'recursive' |
| 61 | + run: | |
| 62 | + pushd tarantool-${{ matrix.tarantool-branch }} |
| 63 | + git submodule update --init --recursive --force |
| 64 | + git fetch origin --prune --progress --recurse-submodules \ |
| 65 | + +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/* |
| 66 | + popd |
| 67 | + shell: bash |
0 commit comments