diff --git a/.github/workflows/example_windows.yml b/.github/workflows/example_windows.yml new file mode 100644 index 0000000..dc057dc --- /dev/null +++ b/.github/workflows/example_windows.yml @@ -0,0 +1,23 @@ +# entry +name: example +on: + workflow_dispatch: + inputs: + token: + description: 'chaitin rivers token' + required: true + type: + description: 'your host type' + required: true + +jobs: + runner: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: collie + if: ${{ inputs.token != '' && inputs.type != '' }} + uses: dvkunion/CollieTrickster@main + with: + token: ${{ inputs.token }} + host_type: ${{ inputs.type }} diff --git a/README.md b/README.md index b4dbdd0..eaee77f 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,14 @@ Collie-Trickster 基于 牧云主机助手 (Collie) 实现的Github Action。主 > 说到底,和大家开了个玩笑,`Collie-Trickster`的目的从一开始就是一个debug工具的定位。 > 任何使用`Collie-Trickster`作恶而导致可能面临的风险,包括github封号的情况,`Collie-Trickster`不承担任何责任。 +**助手限制** +
See More + +牧云主机助手目前默认仅免费三台主机,超过三台主机的使用量时,需要切换付费版本。 +也可以不切换,但是三台以上的机器无法成功注册。 + +
+ **一些其他的声音**
See More @@ -79,13 +87,74 @@ git push 7. 后续使用时可以通过手动触发action的方式。 +8. 关于退出:Linux主机,在百川解绑主机后,ci自动完成。 + +![](https://cdn.dvkunion.cn/tricker/99d6436c64ab49859e5337787a5a3688.png) + + +
-### 高级模版: 通过http触发器自动触发 +### 高级: 切换主机系统(Windows)
CLICK ME
+### 高级: 通过http触发器自动触发的workflow模版 + +
CLICK ME +每次推送代码才能触发实在太蠢了。当然也十分的不够优雅,需要手动把token放在github secrets中。 + +在基础用法的基础上,这里给出一份通过`workflow_dispatch` 利用方式: +```yaml +name: example +on: + workflow_dispatch: + inputs: + token: + description: 'chaitin rivers token' + required: true + type: + description: 'your host type' + required: true + +jobs: + runner: + runs-on: ubuntu-latest # 选择你想要的主机系统如:ubuntu:20.04 + steps: + - uses: actions/checkout@v3 + - name: collie + if: ${{ inputs.token != '' && inputs.type != '' }} + uses: dvkunion/CollieTrickster@main + with: + token: ${{ inputs.token }} + host_type: ${{ inputs.type }} +``` + +使用时,需要你生成一个 [Github Token](https://github.com/settings/tokens/) ,作为认证用;然后将这份`yaml`放在你的仓库`.github/workflows/example.yml`, + +然后发起http请求, 这里给出一个curl的调用: + +```shell +curl \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer "\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos///actions/workflows/example.yml/dispatches \ + -d '{"ref":"main","inputs":{"token":"","type": "linux"}' +``` + +其中: ++ : github配置的token认证 ++ : 你github账户名称 ++ : 你fork的仓库名,一般直接fork的就写`CollieTrickster`即可。 ++ : 长亭牧云主机助手生成的那个Token。 + +这样,每发起一次请求,就会执行一次CI。成功上线一台主机。 + +
+ ## 🎈 更有趣的玩法 如果你有什么更加有趣的想法或建议,欢迎提交 Issue/Pr \ No newline at end of file diff --git a/README_EN.md b/README_EN.md index ae92101..3dda16f 100644 --- a/README_EN.md +++ b/README_EN.md @@ -24,6 +24,16 @@ Collie Trickster is based on the MuYun Virtual Machine Assistant (Collie), Githu > > `Collie Trickster` does not assume any responsibility for any possible risks that may arise from using `Collie Strickster` to commit crimes, including the Github seal.". +**MuYun Virtual Machine Assistant Limit** + +
See More + +Currently, the Mu Virtual Machine Assistant only has three free hosts by default. When the usage of three hosts exceeds, you need to switch to a paid version. + +You can also not switch, but more than three machines cannot successfully register. + +
+ **Some other sounds**
See More @@ -36,6 +46,7 @@ Collie Trickster is based on the MuYun Virtual Machine Assistant (Collie), Githu
CLICK ME + 1. Register for Rivers Platform - Use MuYun Virtual Machine Management Assistant ![](https://cdn.dvkunion.cn/tricker/46fd1775808c4411b8c2f1225641289f.png) @@ -83,12 +94,77 @@ git push 7. During subsequent use, you can manually trigger an action. +8. About exiting: For Linux hosts, ci automatically completes after Rivers unbinds the host. + +![](https://cdn.dvkunion.cn/tricker/99d6436c64ab49859e5337787a5a3688.png) + + + +
+ +### Advanced: Switching host systems (Windows) + +
CLICK ME
-### Advanced template: Automatically triggered through http triggers +### Advanced: Automatically triggered through http triggers workflow template
CLICK ME +It's foolish to trigger every time you push code. Of course, it is not elegant enough. You need to manually place the token in github secrets. + +Based on the basic usage, here is a copy of the `workflow_dispatch` method: + +```yaml +name: example +on: + workflow_dispatch: + inputs: + token: + description: 'chaitin rivers token' + required: true + type: + description: 'your host type' + required: true + +jobs: + runner: + runs-on: ubuntu-latest # 选择你想要的主机系统如:ubuntu:20.04 + steps: + - uses: actions/checkout@v3 + - name: collie + if: ${{ inputs.token != '' && inputs.type != '' }} + uses: dvkunion/CollieTrickster@main + with: + token: ${{ inputs.token }} + host_type: ${{ inputs.type }} +``` + +When using, you need to generate a [Github Token](https://github.com/settings/tokens/) For authentication purposes; + +Then place this' yaml 'in your warehouse'. github/workflows/example. yml ', + +Then initiate a http request, and here is a curl call: + +```shell +curl \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer "\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos///actions/workflows/example.yml/dispatches \ + -d '{"ref":"main","inputs":{"token":"","type": "linux"}' +``` + +Including: + ++ : Token authentication configured for github ++ : Your github account name ++ : The warehouse name of your fork. Generally, if you fork directly, you can write `CollieTrickster`. ++ : The token generated by the MuYun virtual machine assistant. + +This way, the CI is executed every time a request is initiated. and successfully launched a host. +
## 🎈 More fun ways to play diff --git a/action.yml b/action.yml index a12fa44..8ab8ea5 100644 --- a/action.yml +++ b/action.yml @@ -11,23 +11,19 @@ inputs: host_type: description: 'your host type like: linux/windows' default: 'linux' - time: - description: 'continue time, min' - default: '360' runs: using: 'composite' steps: - name: regist-linux-host if: ${{ inputs.host_type == 'linux'}} - run: curl -kfsSL 'http://collie-agent.chaitin.com:1443/api/v1/host/install_script?os_type=linux' | sudo bash -s -- --token=${{ inputs.token }} + run: | + curl -kfsSL 'http://collie-agent.chaitin.com:1443/api/v1/host/install_script?os_type=linux' | sudo bash -s -- --token=${{ inputs.token }} + chmod +x check.sh && ./check.sh shell: bash - name: regist-windows-host if: ${{ inputs.host_type == 'windows'}} run: | Invoke-WebRequest -Uri 'http://collie-agent.chaitin.com:1443/api/v1/lighter/installer?arch=x86_64&os_type=windows&token=${{ inputs.token }}' -OutFile "install.exe" Start-Process install.exe -Wait - shell: powershell - - name: kepp - run: sleep ${{ inputs.time }}m - shell: bash \ No newline at end of file + shell: powershell \ No newline at end of file diff --git a/check.ps1 b/check.ps1 new file mode 100644 index 0000000..77bcf87 --- /dev/null +++ b/check.ps1 @@ -0,0 +1,15 @@ +# 要监听的进程名 +$processName = "collie.exe" + +# 循环监听进程状态 +while ($true) { + # 检查进程状态 + if (Get-Process $processName -ErrorAction SilentlyContinue) { + Write-Host "Process $processName is running" + } else { + Write-Host "Process $processName is not running, exiting script" + exit 0 + } + # 等待 3 秒后再次检查进程状态 + Start-Sleep -Seconds 3 +} \ No newline at end of file diff --git a/check.sh b/check.sh new file mode 100755 index 0000000..611ce9c --- /dev/null +++ b/check.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# 要监听的进程名 +PROCESS_NAME="collie" + +# 循环监听进程状态 +while true +do + # 检查进程状态 + if pgrep "$PROCESS_NAME" >/dev/null 2>&1; then + echo "Process $PROCESS_NAME is running" + else + echo "Process $PROCESS_NAME is not running, exiting script" + exit 0 + fi + # 等待 3 秒后再次检查进程状态 + sleep 3 +done \ No newline at end of file