|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
| 4 | + workflow_run: |
| 5 | + workflows: ["Test"] |
| 6 | + types: |
| 7 | + - completed |
5 | 8 | branches: |
6 | 9 | - main |
7 | 10 | workflow_dispatch: |
@@ -29,60 +32,12 @@ jobs: |
29 | 32 | name: Release |
30 | 33 | runs-on: ubuntu-latest |
31 | 34 | needs: [authorize] |
32 | | - if: always() && (needs.authorize.result == 'success' || needs.authorize.result == 'skipped') |
| 35 | + if: | |
| 36 | + always() && |
| 37 | + (needs.authorize.result == 'success' || needs.authorize.result == 'skipped') && |
| 38 | + (github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success') |
33 | 39 |
|
34 | 40 | steps: |
35 | | - # Wait for tests to complete successfully before releasing |
36 | | - - name: Wait for Test workflow to succeed |
37 | | - if: github.event_name == 'push' |
38 | | - uses: actions/github-script@v7 |
39 | | - with: |
40 | | - script: | |
41 | | - const owner = context.repo.owner; |
42 | | - const repo = context.repo.repo; |
43 | | - const sha = context.sha; |
44 | | - |
45 | | - // Wait for test workflow checks to complete |
46 | | - let attempts = 0; |
47 | | - const maxAttempts = 60; // 10 minutes max wait |
48 | | - |
49 | | - while (attempts < maxAttempts) { |
50 | | - const { data: checks } = await github.rest.checks.listForRef({ |
51 | | - owner, |
52 | | - repo, |
53 | | - ref: sha, |
54 | | - }); |
55 | | - |
56 | | - const testChecks = checks.check_runs.filter(check => |
57 | | - check.name.startsWith('Test (Node 20, ESLint') |
58 | | - ); |
59 | | - |
60 | | - if (testChecks.length === 0) { |
61 | | - console.log('No test checks found yet, waiting...'); |
62 | | - } else { |
63 | | - const allCompleted = testChecks.every(check => check.status === 'completed'); |
64 | | - const allSucceeded = testChecks.every(check => check.conclusion === 'success'); |
65 | | - |
66 | | - if (allCompleted) { |
67 | | - if (allSucceeded) { |
68 | | - console.log('All tests passed successfully!'); |
69 | | - break; |
70 | | - } else { |
71 | | - core.setFailed('Tests failed - cannot proceed with release'); |
72 | | - return; |
73 | | - } |
74 | | - } |
75 | | - console.log(`Waiting for tests to complete... (${testChecks.filter(c => c.status === 'completed').length}/${testChecks.length})`); |
76 | | - } |
77 | | - |
78 | | - await new Promise(resolve => setTimeout(resolve, 10000)); // Wait 10 seconds |
79 | | - attempts++; |
80 | | - } |
81 | | - |
82 | | - if (attempts >= maxAttempts) { |
83 | | - core.setFailed('Timeout waiting for tests to complete'); |
84 | | - } |
85 | | -
|
86 | 41 | - name: Checkout |
87 | 42 | uses: actions/checkout@v4 |
88 | 43 | with: |
|
92 | 47 | - name: Setup Node.js |
93 | 48 | uses: actions/setup-node@v4 |
94 | 49 | with: |
95 | | - node-version: 20 |
| 50 | + node-version: 22 |
96 | 51 | cache: npm |
97 | 52 |
|
98 | 53 | - name: Install dependencies |
|
0 commit comments