Giter Club home page Giter Club logo

Comments (24)

yu-steven avatar yu-steven commented on August 25, 2024

repository_dispatch: #https://www.chenshaowen.com/blog/how-to-trigger-github-action-remotely.html
types:
- Webhook

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

repository_dispatch: #https://www.chenshaowen.com/blog/how-to-trigger-github-action-remotely.html
types:
- Webhook

image

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

repository_dispatch: #https://www.chenshaowen.com/blog/how-to-trigger-github-action-remotely.html
types:
- Webhook

image

我这注释里有个链接没看见吗,就知道问???

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

sleep 45

wehook的时间间隔在哪里设置?其实我一直问它的触发事件到底是什么?什么样的事件才会让wehook开始触发。能像crontab那样的机制可以具体设定不同的日期更加细化的时间间隔吗?

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

image
webhook整个运行过程是不是这样,以上都正确吗
总觉得还差一个重要的控制时间的json脚本文件才齐活
再次问触发事件到底是什么才会让它工作触发

  • 都正确
  • 部分正确

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

sleep 45

wehook的时间间隔在哪里设置?其实我一直问它的触发事件到底是什么?什么样的事件才会让wehook开始触发。能像crontab那样的机制可以具体设定不同的日期更加细化的时间间隔吗?

crontab就是crontab,可以很细化的触发事件,但是GitHub Action的crontab不是很准时
webhook如果可以像crontab一样触发的话那我早就不用crontab了,至于时间间隔,就是那个sleep 45

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

image webhook整个运行过程是不是这样,以上都正确吗 总觉得还差一个重要的控制时间的json脚本文件才齐活 再次问触发事件到底是什么才会让它工作触发

  • 都正确
  • 部分正确

触发事件由webhook.sh的curl命令触发

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

curl通过向指定的链接POST指定的文件json格式的密钥和type即可触发事件

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

还是没明白,听来听去好像是手动的,不是自动的?手动的那老盯着不累呀。简单这样问吧,我想让webhook运行,我需要做什么,指示谁来发什么文件,那个指定的json文件在哪?我没见过。你本地是不是还有个json文件?
image

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

curl -X POST -d 'name=张三' https://api.github.com/repos/yu-steven/openit/dispatches
如果只是这样简单的crul触发,可以运行吗?

curl -X POST https://api.github.com/repos/yu-steven/openit/dispatches -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token $1" --data '{"event_type": "Webhook"}' --silent

这不是一直间隔45秒发送一次嘛,难道45秒就后台运行一次???

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

现在我几乎快看明白了,
如你所说,crontab可以细化,但不准时,wehook无所谓准时,只要触发就干活
如果只是简单的比如我1小时准时运行一次,要求严格就用webhool,设置sleep 3600,如果要求不严格,用crontab也可以,1小时左右呗

其实1小时左右运行一次就行了,半天运行一次也够用,这两种机制其实按刚才说的也没多大区别
但是,我有个建议是,全程最重要的一个文件就是check.yaml,用webhook机制,只要一产生check.yaml,就由代码控制自动发送curl发送 那样指定的表头的请求,运行my job,产生一次订阅,如果非要给时间做个间隔限制,那就对check.yaml做手脚,如以前所说的 whil.sh和start.sh双重利用time out和sleep,也能搞定

如果对准时敏感,那可以把一周时间不同时间段做出不同type的webhook呀,webhook1,就是周一,webook1-5就是周一至周五,webook67就是周六日,if nowtime是,那么自动判断执行webhook几,就行

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

如果再科学一点,其实还是要对clashcheck诞生的check.yaml跟踪,if do循环连续10次,check.yaml里对比10次里的第一次重复率或者改动率不超过50%,then sleep 2h,保留最后结果一次,歇2小时,反正节点源动静也不大。else if超过50%改动,then sleep 30m,注意有动静,可密切关注,30分钟后再来一次,这样的do循环10次为一个批次,来通过节点源上新或者重复率多少来决定干活是该歇歇还是该加班。只要有check.yaml出来,wehook就赶紧发出指令,my job开始搞过来加工,产生一次订阅

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

随你,但是这里我的方法是在action的配置文件里利用curl命令自动在Nodes.yaml运行完后触发Webhook

# Webhook: #触发Webhook启动下一次自动化
# needs: my-job
# runs-on: ubuntu-latest
# steps:
# - name: cURL
# run: curl -s https://raw.githubusercontent.com/yu-steven/openit/main/.github/webhook.sh | bash -s ${{ secrets.webhook }}

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

随你,但是这里我的方法是在action的配置文件里利用curl命令自动在Nodes.yaml运行完后触发Webhook

# Webhook: #触发Webhook启动下一次自动化
# needs: my-job
# runs-on: ubuntu-latest
# steps:
# - name: cURL
# run: curl -s https://raw.githubusercontent.com/yu-steven/openit/main/.github/webhook.sh | bash -s ${{ secrets.webhook }}

你设计的挺好,可你这固定45秒运行一次呀,运行一次nodes.yaml就需要几分钟,还没生产出来,你这45秒就又发送post请求了,这不科学呀

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

curl -X POST https://api.github.com/repos/yu-steven/openit/dispatches -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token $1" --data '{"event_type": "Webhook"}' --silent

这里的token $1",确认这样就行?而不是token ${{ secrets.webhook }}?

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

由于外部shell脚本不能接收到action的秘密变量所以你可以看Nodes.yaml的引用这个脚本后面带了个参数,参数就是那个secret,shell脚本想引入这个参数就是用 $1 引用,后面如果有第二个参数就是用 $2 引用,以此类推,$0 保留为命令本身

# Webhook: #触发Webhook启动下一次自动化
# needs: my-job
# runs-on: ubuntu-latest
# steps:
# - name: cURL
# run: curl -s https://raw.githubusercontent.com/yu-steven/openit/main/.github/webhook.sh | bash -s ${{ secrets.webhook }}

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

随你,但是这里我的方法是在action的配置文件里利用curl命令自动在Nodes.yaml运行完后触发Webhook

# Webhook: #触发Webhook启动下一次自动化
# needs: my-job
# runs-on: ubuntu-latest
# steps:
# - name: cURL
# run: curl -s https://raw.githubusercontent.com/yu-steven/openit/main/.github/webhook.sh | bash -s ${{ secrets.webhook }}

你设计的挺好,可你这固定45秒运行一次呀,运行一次nodes.yaml就需要几分钟,还没生产出来,你这45秒就又发送post请求了,这不科学呀

45s可以改成1m的也就是一分钟,2h就是两个小时

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

还有这个POST请求你可以看到在第85行有一个needs,这控制着这个curl命令只在第一个自动化运行完后运行,确保了完全搜集筛选后触发下一次

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

还有这个POST请求你可以看到在第85行有一个needs,这控制着这个curl命令只在第一个自动化运行完后运行,确保了完全搜集筛选后触发下一次

似的,我调试成功了。你刚才说的如我思维导图里说的那样,运行一次max job后自动通过curl触发下一次,确实你sleep多久就是多久。只是action里有两个job看起来略显累赘

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

还有这个POST请求你可以看到在第85行有一个needs,这控制着这个curl命令只在第一个自动化运行完后运行,确保了完全搜集筛选后触发下一次

似的,我调试成功了。你刚才说的如我思维导图里说的那样,运行一次max job后自动通过curl触发下一次,确实你sleep多久就是多久。只是action里有两个job看起来略显累赘

你也可以把两个job合并起来,把第二个job的run部分放到上面,这样虽然不太清晰,但是会减轻累赘

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

from openit.

yu-steven avatar yu-steven commented on August 25, 2024

没错!我一开始不了解webhook,以为你本地有一个更优于crontab的触发机制,猜想只要check.yaml产生就会触发。我想多了,原来就是一条curl命令,优点也只是准时,做不到细密。我不问你不行,卡壳了,注释那个资料我看了,我以为核心是后台你有个json脚本呢。如果不是你做个自动脚本,它也不是自动的 发自我的iPhone

❤️

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

还是发现2个问题,觉得有必要跟你说一下,可能sleep代码的位置需要调一下,因为测试中发现以下现象
1.如果修改了webhook.sh里的sleep时间间隔,它是不会生效的,除非cancel掉workflow,重新运行nodes.yaml才会生效。
2.我现在设置的时间间隔是 sleep 2000,发现它运行完max job第一项job后,就一直转圈圈,等着下一项curl命令,在action中就像假死了一样。如下图
image
image
image

sleep 45

这行sleep的代码放在job中,它也是其中一个未完的过程项,它就是设置休眠2天,整个工作也是在进行,我觉得放在这不合适,实际是想让它完成后,消停2000秒,而不是让它转圈圈等2000秒。你现在的45秒其实也不合适,总不能一直不间断的生成吧。总之,好像不能用sleep来充当批次间隔。我想要实现的是:30分钟自动运行一次,运行完彻底停止,等30分钟再来一次。

from openit.

anjue39 avatar anjue39 commented on August 25, 2024

1.如果手动触发,在其他电脑就输入下面的?
curl -X POST https://api.github.com/repos/yu-steven/openit/dispatches -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token 真正的token值" --data '{"event_type": "Webhook"}' --silent

2.token值那还输入$1,有效吗?

3.如果不想自动触发,纯手动curl触发,代码该如何改动

from openit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.