半纸鸢 發表於 2021-4-27 20:21:00

GitHub Actions 教程:定时发送天气邮件 weather

<h1 id="page-title" class="asset-name entry-title">GitHub Actions 教程:定时发送天气邮件</h1>
<p>GitHub Actions 教程:定时发送天气邮件 - 阮一峰的网络日志 (ruanyifeng.com)</p>
<p>https://github.com/ChuckFork/weather-action/</p>
<p>&nbsp;</p>
<p>curl -H "Accept-Language: zh-CN" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" -o result.html "https://wttr.in/Shanghai?format=4&amp;m"</p>
<p>需要加上https://的前缀,否则会有一个重定向的提示</p>
<p>&nbsp;</p>
<p>想要在北京时间早上5点收到一封邮件,那么需要倒推8个小时的UTC时间,来发送邮件。</p>
<p>24+5-8=21</p>
<p>所以schedule的时间如下:</p>
<div class="cnblogs_code">
<pre class=""><code>on:
push:
schedule:
    - cron: '0 21 * * *'</code></pre>
</div>
<p>在push以及指定时间进行触发</p>
<p>&nbsp;</p>
<p>邮箱服务器建议使用outlook的office365,</p>
<p>qq邮箱要求授权码,需要手机主动发短信</p>
<p>网易163邮箱注册的时候要求手机主动发短信</p>
<p>&nbsp;</p>
<h1 id="page-title" class="asset-name entry-title">GitHub Actions 入门教程</h1>
<p>https://docs.github.com/en/actions/reference/events-that-trigger-workflows</p>
<p>This example triggers the workflow every day at 5:30 and 17:30 UTC:</p>
<pre class="highlighter-hljs"><code>on:
schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:'30 5,17 * * *'</code></pre>
<p>Cron syntax has five fields separated by a space, and each field represents a unit of time.</p>
<pre class="highlighter-hljs"><code>┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
│ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
│ │ │ │ │                                 
│ │ │ │ │
│ │ │ │ │
* * * * *</code></pre>
<p>You can use these operators in any of the five fields:</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td>*</td>
<td>Any value</td>
<td><code>* * * * *</code> runs every minute of every day.</td>
</tr>
<tr>
<td>,</td>
<td>Value list separator</td>
<td><code>2,10 4,5 * * *</code> runs at minute 2 and 10 of the 4th and 5th hour of every day.</td>
</tr>
<tr>
<td>-</td>
<td>Range of values</td>
<td><code>0 4-6 * * *</code> runs at minute 0 of the 4th, 5th, and 6th hour.</td>
</tr>
<tr>
<td>/</td>
<td>Step values</td>
<td><code>20/15 * * * *</code> runs every 15 minutes starting from minute 20 through 59 (minutes 20, 35, and 50).</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>https://github.com/headllines/github-daily/issues/161</p>
<p>https://github.com/gautamkrishnar/keepalive-workflow</p>
<p>&nbsp;</p><br><br>
来源:https://www.cnblogs.com/chucklu/p/14710742.html
頁: [1]
查看完整版本: GitHub Actions 教程:定时发送天气邮件 weather