diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb572ff..93ed1cc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index a7beaf5..2c398f4 100644 --- a/README.md +++ b/README.md @@ -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** diff --git a/action.yml b/action.yml index 84ce4a5..89bf28d 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 @@ -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