2019-09-29 10:45:29 +08:00
|
|
|
name: remote ssh command
|
2019-09-29 10:43:33 +08:00
|
|
|
on: [push]
|
2022-02-28 07:08:00 +08:00
|
|
|
|
|
|
|
env:
|
|
|
|
FOO: "BAR"
|
|
|
|
BAR: "FOO"
|
|
|
|
|
2019-09-29 10:43:33 +08:00
|
|
|
jobs:
|
2023-04-13 11:15:42 +08:00
|
|
|
testing01:
|
|
|
|
name: default flag testing
|
2019-09-29 10:43:33 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2020-02-13 21:20:15 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: correct password but wrong key
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: ${{ secrets.PASSWORD }}
|
|
|
|
key: "1234"
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: whoami
|
2023-02-28 17:11:47 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: wrong password but correct key
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: "abcdef"
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: whoami
|
2023-02-28 17:11:47 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: executing remote ssh commands using password
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: ${{ secrets.PASSWORD }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: whoami
|
2019-09-29 10:52:20 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: executing remote ssh commands using ssh key
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: whoami
|
2019-09-29 10:53:17 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: multiple command
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: |
|
|
|
|
whoami
|
|
|
|
ls -al
|
2019-09-29 11:16:09 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: stop script if command error
|
|
|
|
uses: ./
|
|
|
|
continue-on-error: true
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
sync: true
|
|
|
|
debug: true
|
|
|
|
script: |
|
|
|
|
mkdir abc/def
|
|
|
|
ls -al
|
2019-09-29 11:16:09 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: ssh key passphrase
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.SSH2 }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
passphrase: ${{ secrets.PASSPHRASE }}
|
|
|
|
script: |
|
|
|
|
whoami
|
|
|
|
ls -al
|
2020-05-24 10:54:31 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: use insecure cipher
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: ${{ secrets.PASSWORD }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script: |
|
2020-08-03 22:15:09 +08:00
|
|
|
ls \
|
|
|
|
-lah
|
2023-12-26 15:07:39 +08:00
|
|
|
use_insecure_cipher: true
|
2020-08-08 12:26:01 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
# https://github.com/appleboy/ssh-action/issues/75#issuecomment-668314271
|
|
|
|
- name: Multiline SSH commands interpreted as single lines
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: ${{ secrets.PASSWORD }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
script: |
|
2020-08-08 12:26:01 +08:00
|
|
|
ls \
|
|
|
|
-lah
|
2023-12-26 15:07:39 +08:00
|
|
|
use_insecure_cipher: true
|
2020-11-17 10:20:18 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
# https://github.com/appleboy/ssh-action/issues/85
|
|
|
|
- name: Deployment to multiple hosts with different ports
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: "${{ secrets.HOST }}:${{ secrets.PORT }}"
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
password: ${{ secrets.PASSWORD }}
|
|
|
|
port: 1024
|
|
|
|
script_stop: true
|
|
|
|
script: |
|
2020-11-17 10:20:18 +08:00
|
|
|
ls \
|
|
|
|
-lah
|
2023-12-26 15:07:39 +08:00
|
|
|
use_insecure_cipher: true
|
2021-03-06 23:00:38 +08:00
|
|
|
|
2022-12-09 10:17:03 +08:00
|
|
|
# - name: SSH ED25519 Private Key
|
|
|
|
# uses: ./
|
|
|
|
# with:
|
|
|
|
# host: ${{ secrets.TUNNEL_HOST }}
|
|
|
|
# username: ${{ secrets.TUNNEL_USERNAME }}
|
|
|
|
# key: ${{ secrets.ID_ED25519 }}
|
|
|
|
# port: ${{ secrets.TUNNEL_PORT }}
|
|
|
|
# script: whoami
|
2023-04-13 11:15:42 +08:00
|
|
|
|
|
|
|
testing02:
|
|
|
|
name: testing with envs
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2023-04-13 11:15:42 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: pass environment
|
|
|
|
uses: ./
|
|
|
|
env:
|
|
|
|
FOO: "BAR"
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
envs: FOO
|
|
|
|
script: |
|
|
|
|
echo "I am $FOO, thanks"
|
|
|
|
echo "I am $BAR, thanks"
|
2023-04-13 11:15:42 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: pass multiple environment
|
|
|
|
uses: ./
|
|
|
|
env:
|
|
|
|
FOO: "BAR"
|
|
|
|
BAR: "FOO"
|
|
|
|
SHA: ${{ github.sha }}
|
|
|
|
PORT: ${{ secrets.PORT }}
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
envs: FOO,BAR,SHA,PORT
|
|
|
|
script: |
|
|
|
|
echo "I am $FOO, thanks"
|
|
|
|
echo "I am $BAR, thanks"
|
|
|
|
echo "sha: $SHA"
|
|
|
|
echo "port: $PORT"
|
|
|
|
sh test.sh
|
2023-04-13 11:15:42 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: custom envs format
|
|
|
|
uses: ./
|
|
|
|
env:
|
|
|
|
FOO: "BAR"
|
|
|
|
AAA: "BBB"
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
envs: FOO,BAR,AAA
|
|
|
|
envs_format: export TEST_{NAME}={VALUE}
|
|
|
|
script: |
|
|
|
|
echo "I am $TEST_FOO, thanks"
|
|
|
|
echo "I am $TEST_BAR, thanks"
|
|
|
|
echo "I am $BAR, thanks"
|
|
|
|
echo "I am $TEST_AAA, thanks"
|
2023-04-13 14:38:24 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: pass all ENV variables to script
|
|
|
|
uses: ./
|
|
|
|
env:
|
|
|
|
INPUT_FOO: "BAR"
|
|
|
|
INPUT_AAA: "BBB"
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
allenvs: true
|
|
|
|
script: |
|
|
|
|
echo "I am $INPUT_FOO, thanks"
|
|
|
|
echo "I am $INPUT_AAA, thanks"
|
|
|
|
echo "$GITHUB_BASE_REF"
|
|
|
|
echo "$GITHUB_REF"
|
2023-07-23 09:53:20 +08:00
|
|
|
|
2023-04-13 14:38:24 +08:00
|
|
|
testing03:
|
|
|
|
name: git clone and pull
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2023-04-13 14:38:24 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: clone private repository
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
script: |
|
|
|
|
git clone https://appleboy:${{ secrets.TEST_TOKEN }}@github.com/go-training/self-runner.git test_repository
|
|
|
|
rm -rf test_repository
|
2023-04-18 09:31:39 +08:00
|
|
|
|
|
|
|
testing04:
|
|
|
|
name: docker login and pull
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2023-04-18 09:31:39 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: login GitHub Container Registry
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
script: |
|
|
|
|
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u github.actor --password-stdin
|
2023-07-23 09:53:20 +08:00
|
|
|
|
2023-12-26 15:07:39 +08:00
|
|
|
- name: login DockerHub Container Registry
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
script: |
|
|
|
|
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
2024-01-07 19:39:23 +08:00
|
|
|
|
|
|
|
testing05:
|
|
|
|
name: switch user
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2024-01-07 19:39:23 +08:00
|
|
|
|
|
|
|
- name: switch to root user
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
|
|
|
script_stop: true
|
|
|
|
request_pty: true
|
|
|
|
command_timeout: 30s
|
|
|
|
script: |
|
|
|
|
whoami && echo 'hello world' && touch todo.txt
|
|
|
|
sudo whoami
|
2024-03-16 15:45:28 +08:00
|
|
|
|
|
|
|
testing06:
|
|
|
|
name: testing ipv6
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
2024-05-04 19:52:33 +08:00
|
|
|
uses: actions/checkout@v4
|
2024-03-16 15:45:28 +08:00
|
|
|
|
|
|
|
- name: Set up WARP
|
|
|
|
uses: fscarmen/warp-on-actions@v1.1
|
|
|
|
with:
|
|
|
|
stack: dual
|
|
|
|
|
|
|
|
- name: testing ipv6 for command
|
|
|
|
run: |
|
|
|
|
curl -m 9 --ipv6 --verbose https://google.com
|
|
|
|
|
|
|
|
- name: testing ipv6
|
|
|
|
uses: ./
|
|
|
|
with:
|
|
|
|
host: 2402:1f00:8000:800::2628
|
|
|
|
username: ubuntu
|
|
|
|
password: ${{ secrets.OVH_PASSWORD }}
|
|
|
|
protocol: tcp6
|
|
|
|
port: 22
|
|
|
|
command_timeout: 30s
|
|
|
|
script: |
|
|
|
|
whoami
|