Apache Airflow Cancel Workflow Runs 项目教程
1. 项目的目录结构及介绍
airflow-cancel-workflow-runs/
├── .github
│ └── workflows
│ └── cancel-workflow-runs.yml
├── action.yml
├── Dockerfile
├── entrypoint.sh
├── LICENSE
├── README.md
└── src
└── main.py
- .github/workflows: 包含GitHub Actions的工作流配置文件。
- action.yml: 定义GitHub Action的元数据和输入输出参数。
- Dockerfile: 用于构建Docker镜像的文件。
- entrypoint.sh: 项目的启动脚本。
- LICENSE: 项目的许可证文件。
- README.md: 项目的说明文档。
- src/main.py: 项目的主要源代码文件。
2. 项目的启动文件介绍
entrypoint.sh
entrypoint.sh
是项目的启动脚本,负责执行主要的逻辑。以下是该文件的基本内容:
#!/bin/sh -l
python /src/main.py
该脚本调用 src/main.py
文件来执行项目的核心功能。
3. 项目的配置文件介绍
action.yml
action.yml
文件定义了GitHub Action的元数据和输入输出参数。以下是该文件的基本内容:
name: 'Cancel Workflow Runs'
description: 'Cancel workflow runs based on specified conditions'
inputs:
cancelMode:
description: 'Mode of cancellation'
required: true
notifyPRCancel:
description: 'Notify PR on cancellation'
required: false
token:
description: 'GitHub token'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
该文件定义了Action的名称、描述、输入参数和运行方式。输入参数包括 cancelMode
、notifyPRCancel
和 token
,分别用于指定取消模式、是否通知PR以及GitHub token。
.github/workflows/cancel-workflow-runs.yml
.github/workflows/cancel-workflow-runs.yml
文件定义了GitHub Actions的工作流配置。以下是该文件的基本内容:
name: Cancel Workflow Runs
on:
workflow_run:
workflows: ['CI']
types: [requested]
jobs:
cancel-self-cancelling-run:
runs-on: ubuntu-latest
steps:
- name: Cancel the self Cancelling workflow run
uses: potiuk/cancel-workflow-runs@master
with:
cancelMode: self
notifyPRCancel: true
token: ${{ secrets.GITHUB_TOKEN }}
该文件定义了工作流的触发条件和执行步骤。当CI工作流被请求时,执行取消操作。
以上是Apache Airflow Cancel Workflow Runs项目的目录结构、启动文件和配置文件的介绍。希望这些内容能帮助你更好地理解和使用该项目。