From 01cb65534f4e65de461d6e996df2a99e1567c6db Mon Sep 17 00:00:00 2001 From: Lewis McNeill Date: Wed, 11 Sep 2024 14:22:55 +0100 Subject: [PATCH 1/2] FIX redirect-to not working for single line values --- entrypoint.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 79da000..173dd7c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,9 +40,13 @@ fi if [ -z "$dest" ]; then kubectl $* else - echo "$dest<> $GITHUB_ENV - kubectl $* >> $GITHUB_ENV - echo "EOF" >> $GITHUB_ENV - - echo "::add-mask::$dest" + output=$(kubectl $*) + if [ $(echo "$output" | wc -l) == 1 ]; then + echo "$dest=$output" >> $GITHUB_OUTPUT + echo "::add-mask::$output" + else + echo "$dest<> $GITHUB_OUTPUT + echo "$output" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + fi fi From 1562776284e50e3d001925f0706c3fb1148a197c Mon Sep 17 00:00:00 2001 From: Lewis McNeill Date: Wed, 11 Sep 2024 14:58:29 +0100 Subject: [PATCH 2/2] CHANGE update README with details about redirect-to argument --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 592614e..564419d 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,24 @@ jobs: args: get pods ``` +## Access output in other steps + +If you want to use the output of the kubectl command in another step, you can use the `redirect-to` option. +```yaml +- uses: actions-hub/kubectl@master + id: get-pods + env: + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + with: + args: get pods + redirect-to: pods +``` + +The output can then be accessed in another step like this: +```yaml +- run: echo "${{ steps.get-pods.outputs.pods }}" +``` + ## Versions If you need a specific version of kubectl, make a PR with a specific version number. After accepting PR the new release will be created.