我的尝试
workflow.yml
:
env:
UPDATE_FREQ: 15
on:
schedule:
- cron: "0/${{ env.UPDATE_FREQ }} * * * *"
出现错误:
invalid `cron` attribute `"0/${{ env.UPDATE_FREQ }} * * * *"`
您无法为 cronjob 定义表达式,因此:
cron: "0/${{ env.UPDATE_FREQ }} * * * *"
无效。或者,如果您想对每个 ENV 执行特定操作,您可以设置多个计划,然后将
github.event.schedule
与您的玉米计划进行比较,例如(来自文档):
on:
schedule:
- cron: '30 5 * * 1,3'
- cron: '30 5 * * 2,4'
jobs:
test_schedule:
runs-on: ubuntu-latest
steps:
- name: Not on Monday or Wednesday
if: github.event.schedule != '30 5 * * 1,3'
run: echo "This step will be skipped on Monday and Wednesday"
- name: Every time
run: echo "This step will always run"
参见: