Tom*_*man 13 workflow continuous-integration yaml github github-actions
这是我目前在 GitHub 上使用的工作流程
name: Windows10 - CI
on: [ push ]
jobs:
run-test:
runs-on: [ self-hosted, windows, DO ]
steps:
- uses: actions/checkout@v2
with:
clean: false
- name: Run nds2 CI - Sanity Test
if: github.ref == 'refs/heads/master'
run: cd c:\actions-runner\_work\nds2\nds2 ; python3 ci_host.py --master
- name: Run nds2 CI - Build Installer
if: github.ref != 'refs/heads/master'
run: cd c:\actions-runner\_work\nds2\nds2 ; python3 ci_host.py
Run Code Online (Sandbox Code Playgroud)
我有一台 Windows 10 计算机,它使用 GitHub 运行程序侦听传入的作业。在传入作业时,如果向 master 分支进行推送,则脚本 ci_host.py 将使用“--master”标志运行,该标志会启动虚拟机并对其运行多个测试。最终,在测试结束时,脚本将虚拟机恢复到预先配置的快照。
所以基本上我想要实现的是,当通过 GitHub actions Web 界面取消作业时,处理测试的脚本将在作业中被取消,并且没有机会将虚拟机恢复到之前的状态干净状态(快照)。
即使作业被取消,如何运行将在工作流程结束时运行的脚本?因此,无论发生什么情况,我的虚拟机都可以恢复到干净的状态
在此先感谢您的帮助 :)
Gui*_*urd 20
您可以使用状态检查功能来执行步骤,具体取决于作业之前发生的情况(或未发生的情况):
successtrue:当前面的步骤均未失败或取消时返回。
always: 总是返回true,即使被取消。当严重故障阻止任务运行时,作业或步骤将不会运行。例如,如果获取源失败。
cancelled:true如果工作流程被取消则返回。
failuretrue:当作业的任何先前步骤失败时返回。
使用示例:
steps:
- name: Execute if the job succeeded
if: ${{ success() }}
- name: Execute if the job failed
if: ${{ failure() }}
- name: Execute if the job was cancelled
if: ${{ cancelled() }}
- name: Always execute
if: ${{ always() }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5027 次 |
| 最近记录: |