Skip to content

Commit

Permalink
feat: Add five points
Browse files Browse the repository at this point in the history
  • Loading branch information
rockyj committed Jan 9, 2025
1 parent e0b008a commit 606ebe3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions .github/workflows/env_approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion backend/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 606ebe3

Please sign in to comment.