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
57 changes: 57 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
setup-jq: true
setup-semver: true
setup-deterministic-zip: true
setup-kubectl: true
kubectl-version: 'v1.33.0'

- name: Verify Setup
run: |
Expand Down Expand Up @@ -132,6 +134,9 @@ jobs:
echo "::group::Verify deterministic-zip Installation"
deterministic-zip --version
echo "::endgroup::"
echo "::group::Verify kubectl Installation"
kubectl version --client
echo "::endgroup::"

test-egress-policy:
name: Test Egress Policy Input
Expand Down Expand Up @@ -613,3 +618,55 @@ jobs:
- name: Verify deterministic-zip Installation
run: |
deterministic-zip --version

test-setup-kubectl:
name: Test Setup kubectl
runs-on: ubuntu-latest
steps:
- name: Harden Runner
id: harden-runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit

- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Run Setup kubectl Action
uses: ./
with:
setup-kubectl: true

- name: Verify kubectl Installation
run: |
kubectl version --client

test-setup-kubectl-custom-version:
name: Test Setup kubectl (custom version)
runs-on: ubuntu-latest
steps:
- name: Harden Runner
id: harden-runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit

- name: Checkout Repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Run Setup kubectl Action (non-default version)
uses: ./
with:
setup-kubectl: true
kubectl-version: 'v1.31.0'

- name: Verify kubectl Version Matches Input
env:
EXPECTED_VERSION: v1.31.0
run: |
ACTUAL="$(kubectl version --client)"
echo "kubectl reported: ${ACTUAL}"
if ! echo "${ACTUAL}" | grep -qF "${EXPECTED_VERSION}"; then
echo "Expected kubectl version ${EXPECTED_VERSION}, got: ${ACTUAL}"
exit 1
fi
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Common steps for initializing a job for GitHub actions. This composite action co
- Security hardening with Step Security's Harden Runner (configurable egress policy)
- Repository checkout with configurable options
- Multi-language support (Node.js, Java, Python, Go, Rust, Swift)
- Build tool setup (Gradle, Task, gomplate, jq)
- Build tool setup (Gradle, Task, gomplate, jq, kubectl)
- Automatic caching for dependencies and build artifacts

## Usage
Expand Down Expand Up @@ -175,6 +175,13 @@ Common steps for initializing a job for GitHub actions. This composite action co
> per-platform SHA-256 (fail-closed) rather than the release's own `.sha256` sidecar, so an
> upstream asset swap is rejected. Supports Linux/macOS on `amd64`/`arm64`.

**kubectl**

| Input | Description | Required | Default |
|-----------------|---------------------------|----------|---------|
| setup-kubectl | Whether to setup kubectl | No | false |
| kubectl-version | kubectl version to use | No | v1.33.0 |

### Outputs

**Checkout Outputs**
Expand Down
24 changes: 24 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ inputs:
description: 'Whether to setup deterministic-zip'
required: false
default: 'false'
setup-kubectl:
description: 'Whether to setup kubectl'
required: false
default: 'false'
kubectl-version:
description: 'kubectl version to use (e.g. v1.33.0)'
required: false
default: 'v1.33.0'

# expose outputs from the sub-actions
outputs:
Expand Down Expand Up @@ -657,6 +665,22 @@ runs:
deterministic-zip --version
echo "::endgroup::"

- name: Set Up KubeCtl Parameters
Comment thread
andrewb1269 marked this conversation as resolved.
id: setup-kubectl-params
if: ${{ inputs.setup-kubectl == 'true' }}
shell: bash
run: |
echo "::group::Setting up KubeCtl"
echo "Version: ${{ inputs.kubectl-version }}"
echo "::endgroup::"

- name: Install KubeCtl
id: setup-kubectl
if: ${{ inputs.setup-kubectl == 'true' }}
uses: azure/setup-kubectl@829323503d1be3d00ca8346e5391ca0b07a9ab0d # v5.1.0
with:
version: ${{ inputs.kubectl-version }}

branding:
icon: 'arrow-up-right'
color: 'green'
Loading