Skip to content

Commit

Permalink
Merge pull request #4 from DVKunion/feat/v1.1.1
Browse files Browse the repository at this point in the history
feat: v1.1.1
  • Loading branch information
DVKunion authored Mar 31, 2023
2 parents 5f16777 + 7be6c7c commit ca8fa13
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 10 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/example_windows.yml
Original file line number Diff line number Diff line change
@@ -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 }}
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Collie-Trickster 基于 牧云主机助手 (Collie) 实现的Github Action。主
> 说到底,和大家开了个玩笑,`Collie-Trickster`的目的从一开始就是一个debug工具的定位。
> 任何使用`Collie-Trickster`作恶而导致可能面临的风险,包括github封号的情况,`Collie-Trickster`不承担任何责任。
**助手限制**
<details><summary>See More</summary>

牧云主机助手目前默认仅免费三台主机,超过三台主机的使用量时,需要切换付费版本。
也可以不切换,但是三台以上的机器无法成功注册。

</details>

**一些其他的声音**
<details><summary>See More</summary>

Expand Down Expand Up @@ -79,13 +87,74 @@ git push

7. 后续使用时可以通过手动触发action的方式。

8. 关于退出:Linux主机,在百川解绑主机后,ci自动完成。

![](https://cdn.dvkunion.cn/tricker/99d6436c64ab49859e5337787a5a3688.png)



</details>

### 高级模版: 通过http触发器自动触发
### 高级: 切换主机系统(Windows)

<details><summary>CLICK ME</summary>
</details>

### 高级: 通过http触发器自动触发的workflow模版

<details><summary>CLICK ME</summary>
每次推送代码才能触发实在太蠢了。当然也十分的不够优雅,需要手动把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 <YOUR_GITHUB_ACTION>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/<YOUR_GITHUB_USER_NAME>/<YOUR_GITHUB_REPOS>/actions/workflows/example.yml/dispatches \
-d '{"ref":"main","inputs":{"token":"<YOUR_TOKEN>","type": "linux"}'
```

其中:
+ <YOUR_GITHUB_ACTION>: github配置的token认证
+ <YOUR_GITHUB_USER_NAME>: 你github账户名称
+ <YOUR_GITHUB_REPOS>: 你fork的仓库名,一般直接fork的就写`CollieTrickster`即可。
+ <YOUR_TOKEN>: 长亭牧云主机助手生成的那个Token。

这样,每发起一次请求,就会执行一次CI。成功上线一台主机。

</details>

## 🎈 更有趣的玩法

如果你有什么更加有趣的想法或建议,欢迎提交 Issue/Pr
78 changes: 77 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

<details><summary>See More</summary>

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.

</details>

**Some other sounds**

<details><summary>See More</summary>
Expand All @@ -36,6 +46,7 @@ Collie Trickster is based on the MuYun Virtual Machine Assistant (Collie), Githu

<details><summary>CLICK ME</summary>


1. Register for Rivers Platform - Use MuYun Virtual Machine Management Assistant

![](https://cdn.dvkunion.cn/tricker/46fd1775808c4411b8c2f1225641289f.png)
Expand Down Expand Up @@ -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)



</details>

### Advanced: Switching host systems (Windows)

<details><summary>CLICK ME</summary>
</details>

### Advanced template: Automatically triggered through http triggers
### Advanced: Automatically triggered through http triggers workflow template

<details><summary>CLICK ME</summary>

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 <YOUR_GITHUB_ACTION>"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/<YOUR_GITHUB_USER_NAME>/<YOUR_GITHUB_REPOS>/actions/workflows/example.yml/dispatches \
-d '{"ref":"main","inputs":{"token":"<YOUR_TOKEN>","type": "linux"}'
```
Including:
+ <YOUR_ GITHUB_ACTION>: Token authentication configured for github
+ <YOUR_ GITHUB_USER_NAME>: Your github account name
+ <YOUR_ GITHUB_REPOS>: The warehouse name of your fork. Generally, if you fork directly, you can write `CollieTrickster`.
+ <YOUR_ TOKEN>: 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.

</details>

## 🎈 More fun ways to play
Expand Down
12 changes: 4 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
shell: powershell
15 changes: 15 additions & 0 deletions check.ps1
Original file line number Diff line number Diff line change
@@ -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
}
18 changes: 18 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ca8fa13

Please sign in to comment.