diff --git a/.github/workflows/env_approval.yml b/.github/workflows/env_approval.yml index 246e803..cb396e3 100644 --- a/.github/workflows/env_approval.yml +++ b/.github/workflows/env_approval.yml @@ -86,18 +86,28 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const services = ${{ needs.detect-changes.outputs.affected_services || '[]' }}; - console.log('Detected services:', services); + // 获取检测到的服务 + const detectedServices = ${{ needs.detect-changes.outputs.affected_services || '[]' }}; + console.log('Detected services:', detectedServices); - if (services.length === 0 && '${{ github.event_name }}' === 'push') { + // 处理手动触发的情况 + const isManualTrigger = '${{ github.event_name }}' === 'workflow_dispatch'; + const manualSelection = '${{ github.event.inputs.services }}'; + + let selectedServices; + if (isManualTrigger) { + // 如果是手动触发 + selectedServices = manualSelection === 'all' ? detectedServices : [manualSelection]; + } else { + // 如果是自动触发(push 事件) + selectedServices = detectedServices; + } + + if (selectedServices.length === 0 && '${{ github.event_name }}' === 'push') { core.setFailed('No service changes detected'); return; } - const selectedServices = '${{ github.event.inputs.services }}' === 'all' - ? services - : ['${{ github.event.inputs.services }}']; - console.log('Selected services for deployment:', selectedServices); core.setOutput('selected_services', JSON.stringify(selectedServices)); diff --git a/backend/src/index.js b/backend/src/index.js index f885a8f..4e50139 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -9,7 +9,7 @@ const PORT = process.env.PORT || 3000; // 触发GitHub repository dispatch事件的函数 async function triggerGithubDispatch(owner, repo, token) { - console.log(`[${new Date().toISOString()}] 开始触发GitHub Dispatch事件....`); + console.log(`[${new Date().toISOString()}] 开始触发GitHub Dispatch事件.....`); console.log(`[${new Date().toISOString()}] 目标仓库: ${owner}/${repo}`); try {