git 部署触发
I have a list of scheduled posts that I want to publish every week on my blog, and I try to stay a few days ahead of that queue to have room for when I’m unable to write, or if I want to take a break.
我有一个预定的帖子列表,我想每周在我的博客上发布,并且我尝试在该队列之前保留几天,以便在我无法写作或想休息时有空间。
I find consistency is very important to keep the momentum going for my work. Since two months I post every day from Monday to Saturday, and I want to do so in the future as well, as I really like doing it.
我发现保持一致性对于保持工作势头非常重要。 自从两个月以来,我每天从星期一到星期六发帖,而且我以后也想这样做,因为我真的很喜欢这样做。
I use the Hugo Static Site Generator, hosted on Netlify.
我使用Netlify上托管的Hugo Static Site Generator 。
It’s an amazing combination of tools, and I’m very happy with the blog setup.
这是工具的惊人组合,我对博客设置非常满意。
Today I was out hiking on a mountain when I realized I got past my usual posting time, and I didn’t publish the blog post I already scheduled.
今天,当我意识到自己已经超出了通常的发布时间,并且没有发布已经安排好的博客帖子时,我正在山上远足。
With Hugo I can set a post date in the future, and when the site is rebuilt using the hugo
CLI command, that post is not included in the resulting HTML, as it’s a future post.
使用Hugo,我可以设置将来的发布日期,并且当使用hugo
CLI命令重建网站时,该发布不包括在生成HTML中,因为它是将来的发布。
Netlify has this nice concept of building the Hugo site on their servers, so what I need to do is just trigger a new deploy. Usually deploys happen when I push something to GitHub - Netlify is alerted automatically and deploys in a minute or less.
Netlify具有在其服务器上构建Hugo站点的良好概念,因此我要做的只是触发新的部署。 通常,当我将某些内容推送到GitHub时就会发生部署-Netlify会自动收到警报,并在一分钟或更短时间内部署完毕。
In this case I needed to manually trigger a deploy on Netlify so I logged in using my iPhone, and clicked “Trigger deploy”.
在这种情况下,我需要在Netlify上手动触发部署,因此我使用iPhone登录,然后单击“触发部署”。
This action rebuilt the static site using Hugo, on the server side, and I just put my phone back in the pocket.
此操作使用服务器端的Hugo重建了静态站点,我只是将手机放回了口袋。
The blog post launched 🎉 and I just tweeted about it.
博客文章启动了🎉,而我刚刚在推特上发布了此消息。
As I was walking, I realized I can automate all this stuff.
当我走路时,我意识到我可以使所有这些东西自动化。
I just need to trigger a deploy automatically every day at 9AM, somehow. So I looked on the Netlify interface if they had any kind of automated timer for recurring deploys. There is no such feature, however they have a WebHook endpoint.
我只需要每天以某种方式在上午9点自动触发部署。 因此,我查看了Netlify界面,看看他们是否具有用于重复部署的任何自动计时器。 没有此类功能,但是它们具有WebHook终结点。
So I looked for something that I can configure to POST to the WebHook every day. Enter Zapier.
因此,我一直在寻找可以配置为每天发布到WebHook的内容。 输入Zapier 。
Zapier is a tool that’s all about automation.
Zapier是一个全自动化的工具。
Googling around I found a Zap to send a WebHook POST request on a daily schedule, and that’s exactly what I needed.
在Google上四处搜寻,我发现了一个Zap,可以每天发送一个WebHook POST请求 ,而这正是我所需要的。
Now, on Netlify I just created a WebHook URL
现在,在Netlify上,我刚刚创建了一个WebHook URL
which gave me a custom URL to call:
这给了我一个自定义的URL来调用:
I just pasted the URL on Zapier, and set it up to make an empty POST request to my Netlify hook:
我只是将URL粘贴在Zapier上,并将其设置为对Netlify钩子发出一个空POST请求:
and the testing manually-triggered Zap deploy worked:
手动触发的Zap部署测试工作了:
I’m happy now! I just have to create content, push it to GitHub with the scheduled date, and don’t worry about deploying any more! 🌈 🎉 👨🏼💻
我现在很高兴! 我只需要创建内容,并按计划的日期将其推送到GitHub,就不用担心再部署了! 🌈🎉👨🏼💻
git 部署触发