我正在运行 javascript github 操作示例,当我有
在:[推]
但不是当我有
on:
schedule:
- cron: '*/5 * * * *'
Run Code Online (Sandbox Code Playgroud)
我希望 github 操作每 5 分钟运行一次,但它似乎根本没有运行。
这是我的其余代码供参考
.github/worflows/main.yml
on:
schedule:
- cron: '*/5 * * * *'
jobs:
hello_world_job:
runs-on: ubuntu-latest
name: A job to say hello
steps:
- name: Hello world action step
id: hello
uses: StephenVNelson/website/@3-experiment-with-actions
with:
who-to-greet: 'Mona the Octocat'
# Use the output from the `hello` step
- name: Get the output time
run: echo "The time was ${{ steps.hello.outputs.time }}"
Run Code Online (Sandbox Code Playgroud)
./action.yml
name: 'Hello World'
description: 'Greet someone and record the time'
inputs:
who-to-greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'node12'
main: './github-actions/main.js'
Run Code Online (Sandbox Code Playgroud)
./github-actions/main.js
const core = require('@actions/core');
const github = require('@actions/github');
try {
// `who-to-greet` input defined in action metadata file
const nameToGreet = core.getInput('who-to-greet');
console.log(`Hello ${nameToGreet}!`);
const time = (new Date()).toTimeString();
core.setOutput("time", time);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);
} catch (error) {
core.setFailed(error.message);
}
Run Code Online (Sandbox Code Playgroud)
小智 7
(编者注:对于未来的读者,请阅读此答案的评论以获取频率更新。)
您无法将其安排为每 5 分钟一次,因为“您可以运行计划工作流程的最短间隔是每 15 分钟一次”:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
将其更改为 '*/15 * * * *' 就可以了。
正如有关计划事件的GitHub 文档中提到的
在 GitHub Actions 工作流运行的高负载期间,计划事件可能会延迟。高负载时间包括每小时的开始时间。为了减少延迟的可能性,请将工作流程安排在每小时的不同时间运行。
进一步阅读:无法保证预定的工作?
| 归档时间: |
|
| 查看次数: |
4247 次 |
| 最近记录: |