返回部落格
2026 年 4 月 1 日指南· 6 分鐘閱讀

從 GitHub Actions 到 OSOP:轉換你現有的工作流程

OSOP 團隊

你不需要從頭開始。OSOP 的格式轉換器(osop-interop)從 6 種流行格式匯入現有工作流程——並匯出回其中 4 種。本指南展示如何將你的 GitHub Actions、Airflow DAG 和 BPMN 流程轉換為 OSOP。

安裝

install.sh
pip install osop-interop

支援的格式

格式匯入匯出
GitHub Actions
BPMN
Apache Airflow
Temporal
Postman Collections
OpenAPI 3.x

範例:GitHub Actions 到 OSOP

假設你在 .github/workflows/deploy.yml 中有一個 CI/CD 工作流程:

.github/workflows/deploy.yml
# .github/workflows/deploy.yml
name: Deploy
on: [push]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm test
  build:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - run: npm run build
  deploy:
    needs: build
    environment: production
    runs-on: ubuntu-latest
    steps:
      - run: ./deploy.sh

將它轉換為 OSOP:

terminal
$ osop import .github/workflows/deploy.yml --from github-actions -o deploy.osop.yaml

結果:

deploy.osop.yaml
Testcicd
sequentialBuild
Buildcli
sequentialDeploy
Deployinfra

注意轉換器自動偵測到 environment: production 宣告並將其轉換為 approval_gate。工作依賴(needs:)變成循序邊。

轉換對應

GitHub Actions 到 OSOP

GitHub ActionsOSOP
workflowOsopWorkflow
jobnode (step/fork/join)
stepstep node
if: conditiondecision node
needs: dependencyedge ordering
on: scheduletimer node
environment: productionapproval node

Airflow 到 OSOP

AirflowOSOP
DAGOsopWorkflow
BashOperatorcli step
PythonOperatorstep node
BranchPythonOperatordecision node
>> dependenciesedge
schedule_intervaltimer node

BPMN 到 OSOP

BPMNOSOP
Start Eventstart node
Service Taskstep node
User Taskapproval node
Exclusive Gatewaydecision node
Parallel Gatewayfork/join
Timer Eventtimer node
Sub-Processsubprocess

匯出回原格式

OSOP 不是單向的。匯出回你的執行環境格式:

export.sh
# Export to GitHub Actions
$ osop export deploy.osop.yaml --to github-actions -o .github/workflows/deploy.yml

# Export to Airflow DAG
$ osop export pipeline.osop.yaml --to airflow -o dags/pipeline.py

# Export to BPMN
$ osop export process.osop.yaml --to bpmn -o process.bpmn

使用 Python API

python-api.py
from osop_interop import GitHubActionsImporter, AirflowExporter

# Import
importer = GitHubActionsImporter()
osop_workflow = importer.convert("path/to/workflow.yml")

# Export
exporter = AirflowExporter()
airflow_dag = exporter.convert("path/to/workflow.osop.yaml")

通過 MCP 使用

如果你安裝了 OSOP MCP 伺服器,你的 AI Agent 可以通過單一工具呼叫轉換工作流程:

mcp-call.json
// Agent calls osop.import
{
  "tool": "osop.import",
  "arguments": {
    "file_path": ".github/workflows/deploy.yml",
    "source_format": "github-actions"
  }
}
// Returns valid OSOP YAML

為什麼要轉換?

轉換為 OSOP 讓你獲得:

  • 可攜性 — 你的工作流程適用於 18 個 AI 程式 Agent 和多個執行環境
  • 執行記錄 — .osoplog 捕捉實際發生的事,你目前的格式不會
  • 風險分析 — GitHub Actions YAML 不提供的內建安全掃描
  • 視覺編輯 — 在 OSOP 編輯器中拖放你的工作流程
  • 最佳化 — 比較多次執行以找出需要改進的地方

而且你隨時可以匯出回原格式。OSOP 是升級,不是遷移。