Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redirect-to argument #37

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ fi
if [ -z "$dest" ]; then
kubectl $*
else
echo "$dest<<EOF" >> $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<<EOF" >> $GITHUB_OUTPUT
echo "$output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
fi