self-hosted github-runner ssh 登录其他主机

应用场景:自己搭建的 github runner,要使用这个 runner 去控制另一台机器,去做事情。

准备

  1. 把部署 github runner 的这台机器的 ssh public key 使用 ssh-copy-id 复制到要 ssh 登录到的目标机器
  2. 部署 github runner 的这台机器的 ssh private key 添加到 github 的 secrets 里,在 actions 里要使用这个 private key

编写 ci.yml


jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    # 自己搭建的 runner 的 label
    runs-on: integration 

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - name: Run a command remotely on target host
        uses: docker://evaneos/ssh-action:0.1.0
        with:
          hosts: target host ip
          user: root
          private_key: ${{ secrets.PRIVATE_SSH_KEY_INTEGRATION_RUNNER }}
          #knock_sequence: ${{ secrets.KNOCK_SEQUENCE }}
          commands: |
            echo "I can run..."
            echo "...multiple commands"
            pwd
            who

job 根据 runs-on 指定的 label 选择 runner

在这里插入图片描述

References

  1. docker://evaneos/ssh-action:0.1.0
  2. selfhosted-github-runner
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值