mirror of
https://github.com/appleboy/ssh-action.git
synced 2026-01-28 23:13:15 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ff4204d59 | ||
|
|
8e460a28f2 | ||
|
|
23bd972bfc |
96
.github/workflows/main.yml
vendored
96
.github/workflows/main.yml
vendored
@@ -609,6 +609,102 @@ jobs:
|
||||
- name: check stdout
|
||||
run: |
|
||||
echo "stdout: ${{ steps.stdout.outputs.stdout }}"
|
||||
if [ -z "${{ steps.stdout.outputs.stdout }}" ]; then
|
||||
echo "Error: stdout is empty"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- id: stdout-multiline
|
||||
name: capture multiline output
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ env.REMOTE_HOST }}
|
||||
username: linuxserver.io
|
||||
password: password
|
||||
port: 2222
|
||||
capture_stdout: true
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
echo "Line 1"
|
||||
echo "Line 2"
|
||||
echo "Line 3"
|
||||
whoami
|
||||
pwd
|
||||
|
||||
- name: check multiline output
|
||||
run: |
|
||||
echo "stdout: ${{ steps.stdout-multiline.outputs.stdout }}"
|
||||
# Check if all lines are present
|
||||
if ! echo "${{ steps.stdout-multiline.outputs.stdout }}" | grep -q "Line 1"; then
|
||||
echo "Error: 'Line 1' not found in output"
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "${{ steps.stdout-multiline.outputs.stdout }}" | grep -q "Line 2"; then
|
||||
echo "Error: 'Line 2' not found in output"
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "${{ steps.stdout-multiline.outputs.stdout }}" | grep -q "Line 3"; then
|
||||
echo "Error: 'Line 3' not found in output"
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "${{ steps.stdout-multiline.outputs.stdout }}" | grep -q "linuxserver.io"; then
|
||||
echo "Error: username not found in output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for duplicates - each unique line should appear exactly once
|
||||
OUTPUT="${{ steps.stdout-multiline.outputs.stdout }}"
|
||||
LINE1_COUNT=$(echo "$OUTPUT" | grep -c "^Line 1$" || true)
|
||||
LINE2_COUNT=$(echo "$OUTPUT" | grep -c "^Line 2$" || true)
|
||||
LINE3_COUNT=$(echo "$OUTPUT" | grep -c "^Line 3$" || true)
|
||||
|
||||
echo "Line 1 count: $LINE1_COUNT"
|
||||
echo "Line 2 count: $LINE2_COUNT"
|
||||
echo "Line 3 count: $LINE3_COUNT"
|
||||
|
||||
if [ "$LINE1_COUNT" -ne 1 ]; then
|
||||
echo "Error: 'Line 1' appears $LINE1_COUNT times (expected 1)"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$LINE2_COUNT" -ne 1 ]; then
|
||||
echo "Error: 'Line 2' appears $LINE2_COUNT times (expected 1)"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$LINE3_COUNT" -ne 1 ]; then
|
||||
echo "Error: 'Line 3' appears $LINE3_COUNT times (expected 1)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✓ No duplicate lines detected"
|
||||
|
||||
- id: stdout-with-special-chars
|
||||
name: capture output with special characters
|
||||
uses: ./
|
||||
with:
|
||||
host: ${{ env.REMOTE_HOST }}
|
||||
username: linuxserver.io
|
||||
password: password
|
||||
port: 2222
|
||||
capture_stdout: true
|
||||
script: |
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
echo "Test with special chars: @#$%^&*()"
|
||||
echo "Path: /home/user/test"
|
||||
echo "JSON: {\"key\": \"value\"}"
|
||||
|
||||
- name: check special characters output
|
||||
run: |
|
||||
echo "stdout: ${{ steps.stdout-with-special-chars.outputs.stdout }}"
|
||||
if ! echo "${{ steps.stdout-with-special-chars.outputs.stdout }}" | grep -q "special chars"; then
|
||||
echo "Error: special characters test failed"
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "${{ steps.stdout-with-special-chars.outputs.stdout }}" | grep -q "/home/user/test"; then
|
||||
echo "Error: path not found in output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
testing-script-stop:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -45,11 +45,13 @@ English | [繁體中文](./README.zh-tw.md) | [简体中文](./README.zh-cn.md)
|
||||
**SSH for GitHub Actions** is a powerful [GitHub Action](https://github.com/features/actions) for executing remote SSH commands easily and securely in your CI/CD workflows.
|
||||
Built with [Golang](https://go.dev) and [drone-ssh](https://github.com/appleboy/drone-ssh), it supports a wide range of SSH scenarios, including multi-host, proxy, and advanced authentication.
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/main.yml)
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/trivy-scan.yml)
|
||||
|
||||
**Slides:** [SSH for GitHub Actions](https://speakerdeck.com/appleboy/ssh-for-github-actions)
|
||||
|
||||
---
|
||||
|
||||
## 🧩 Core Concepts & Input Parameters
|
||||
@@ -127,8 +129,8 @@ These parameters control the use of a proxy (jump host) for connecting to your t
|
||||
|
||||
This action provides the following outputs that you can use in subsequent steps:
|
||||
|
||||
| Output | Description |
|
||||
| ------ | ----------------------------------------------------------------- |
|
||||
| Output | Description |
|
||||
| ------ | -------------------------------------------------------------------------- |
|
||||
| stdout | Standard output of the executed commands (requires `capture_stdout: true`) |
|
||||
|
||||
---
|
||||
|
||||
@@ -45,11 +45,13 @@
|
||||
**SSH for GitHub Actions** 是一个强大的 [GitHub Action](https://github.com/features/actions),可让你在 CI/CD 工作流中轻松且安全地执行远程 SSH 命令。
|
||||
本项目基于 [Golang](https://go.dev) 和 [drone-ssh](https://github.com/appleboy/drone-ssh) 构建,支持多主机、代理、高级认证等多种 SSH 场景。
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/main.yml)
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/trivy-scan.yml)
|
||||
|
||||
**幻灯片:** [SSH for GitHub Actions](https://speakerdeck.com/appleboy/ssh-for-github-actions)
|
||||
|
||||
---
|
||||
|
||||
## 🧩 核心概念与输入参数
|
||||
|
||||
@@ -45,11 +45,13 @@
|
||||
**SSH for GitHub Actions** 是一個強大的 [GitHub Action](https://github.com/features/actions),可讓你在 CI/CD 工作流程中輕鬆且安全地執行遠端 SSH 指令。
|
||||
本專案以 [Golang](https://go.dev) 和 [drone-ssh](https://github.com/appleboy/drone-ssh) 建立,支援多主機、代理、進階認證等多種 SSH 場景。
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/main.yml)
|
||||
[](https://github.com/appleboy/ssh-action/actions/workflows/trivy-scan.yml)
|
||||
|
||||
**簡報:** [SSH for GitHub Actions](https://speakerdeck.com/appleboy/ssh-for-github-actions)
|
||||
|
||||
---
|
||||
|
||||
## 🧩 核心概念與輸入參數
|
||||
|
||||
@@ -71,11 +71,9 @@ if ! "${TARGET}" --version; then
|
||||
fi
|
||||
echo "======================================="
|
||||
if [[ "${INPUT_CAPTURE_STDOUT}" == 'true' ]]; then
|
||||
{
|
||||
echo 'stdout<<EOF'
|
||||
"${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"
|
||||
echo 'EOF'
|
||||
} >>"${GITHUB_OUTPUT}"
|
||||
echo 'stdout<<EOF' >> "${GITHUB_OUTPUT}"
|
||||
"${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"
|
||||
echo 'EOF' >> "${GITHUB_OUTPUT}"
|
||||
else
|
||||
"${TARGET}" "$@"
|
||||
fi
|
||||
|
||||
BIN
images/ssh-agent.png
Normal file
BIN
images/ssh-agent.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 652 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 70 KiB |
Reference in New Issue
Block a user