Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,36 @@ jobs:
echo "Is Shallow Repository: ${shallow_value}"
test "${shallow_value}" = "true"

test-sparse-checkout:
name: Test Sparse Checkout Action
runs-on: ubuntu-latest
steps:
- name: Harden Runner
id: harden-runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit

- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Run Sparse Checkout Action
uses: ./
id: test-sparse-checkout
with:
checkout: true
checkout-ref: main
checkout-token: ${{ secrets.GITHUB_TOKEN }}
checkout-sparse: '.github'

- name: Verify Sparse Checkout Outputs
run: |
echo "Checkout Ref: ${{ steps.test-sparse-checkout.outputs.checkout-ref }}"
echo "Checkout Commit: ${{ steps.test-sparse-checkout.outputs.checkout-commit }}"
sparse_list=$(git sparse-checkout list)
echo "sparse list: ${sparse_list}"
test "${sparse_list}" = ".github"

test-setup-java:
name: Test Setup Java Action
runs-on: ubuntu-latest
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ Common steps for initializing a job for GitHub actions. This composite action co

**Repository Checkout**

| Input | Description | Required | Default | Options |
|----------------------|------------------------------------------------------------------------------|----------|---------|----------------------------|
| checkout | Whether to checkout the repository | No | - | `true`/`false` |
| checkout-ref | The branch, tag or SHA to checkout | No | - | any `branch`/`tag`/`SHA` |
| checkout-token | Personal access token (PAT) used to fetch the repository | No | - | `Token` used for checkout |
| checkout-path | Path to checkout the repository into (relative to `${GITHUB_WORKSPACE}`) | No | `.` | any relative path |
| checkout-fetch-depth | Depth of commit history to fetch | No | 1 | `0` (full)/`1`/`2`/... |
| checkout-persist | Whether to configure the token with the local git config | No | true | `true`/`false` |
| checkout-submodules | Whether to fetch submodules | No | false | `true`/`false`/`recursive` |
| Input | Description | Required | Default | Options |
|-----------------------------|--------------------------------------------------------------------------|----------|---------|----------------------------|
| checkout | Whether to checkout the repository | No | - | `true`/`false` |
| checkout-ref | The branch, tag or SHA to checkout | No | - | any `branch`/`tag`/`SHA` |
| checkout-token | Personal access token (PAT) used to fetch the repository | No | - | `Token` used for checkout |
| checkout-path | Path to checkout the repository into (relative to `${GITHUB_WORKSPACE}`) | No | `.` | any relative path |
| checkout-fetch-depth | Depth of commit history to fetch | No | 1 | `0` (full)/`1`/`2`/... |
| checkout-persist | Whether to configure the token with the local git config | No | true | `true`/`false` |
| checkout-submodules | Whether to fetch submodules | No | false | `true`/`false`/`recursive` |
| checkout-sparse | Do a sparse checkout on given patterns | No | - | path |
| checkout-sparse-cone-mode | Specifies whether to use cone-mode when doing a sparse checkout | No | true | |

**Java**

Expand Down
15 changes: 15 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ inputs:
description: 'Whether to checkout submodules (true/false/recursive)'
default: 'false'
required: false
checkout-sparse:
description: >
Do a sparse checkout on given patterns.
Each pattern should be separated with new lines.
default: null
required: false
checkout-sparse-cone-mode:
description: >
Specifies whether to use cone-mode when doing a sparse checkout.
default: true
required: false
setup-node:
description: 'Whether to setup Node.js'
required: false
Expand Down Expand Up @@ -259,6 +270,8 @@ runs:
echo "Ref: ${{ inputs.checkout-ref }}"
echo "Fetch Depth: ${{ inputs.checkout-fetch-depth }}"
echo "Submodules: ${{ inputs.checkout-submodules }}"
echo "Sparse: ${{inputs.checkout-sparse }}"
echo "Sparse Cone Mode: ${{inputs.checkout-sparse-cone-mode }}"
echo "::endgroup::"

- name: Checkout Code
Expand All @@ -272,6 +285,8 @@ runs:
token: ${{ inputs.checkout-token }}
path: ${{ inputs.checkout-path }}
persist-credentials: ${{ inputs.checkout-persist }}
sparse-checkout: ${{ inputs.checkout-sparse }}
sparse-checkout-cone-mode: ${{inputs.checkout-sparse-cone-mode }}

- name: Set Up Java Parameters
id: setup-java-params
Expand Down
Loading