|
1 | 1 | name: UI Tests |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_run: |
5 | | - workflows: ["CI"] |
6 | | - types: |
7 | | - - completed |
| 4 | + push: |
8 | 5 | branches: [ "master" ] |
9 | 6 | workflow_dispatch: |
10 | 7 |
|
|
13 | 10 | runs-on: ubuntu-latest |
14 | 11 | outputs: |
15 | 12 | should_run: ${{ steps.check-pr-status.outputs.should_run }} |
16 | | - pr_number: ${{ steps.find-pr.outputs.pr_number }} |
17 | | - |
18 | | - steps: |
19 | | - - name: Find associated pull request |
20 | | - id: find-pr |
21 | | - uses: actions/github-script@v7 |
22 | | - with: |
23 | | - script: | |
24 | | - const commitSha = '${{ github.event.workflow_run.head_sha }}'; |
25 | | - const { data: pullRequests } = await github.rest.pulls.list({ |
26 | | - owner: context.repo.owner, |
27 | | - repo: context.repo.repo, |
28 | | - state: 'open', |
29 | | - sort: 'updated', |
30 | | - direction: 'desc', |
31 | | - per_page: 100 |
32 | | - }); |
33 | | -
|
34 | | - for (const pr of pullRequests) { |
35 | | - if (pr.head.sha === commitSha) { |
36 | | - console.log(`Found matching PR: #${pr.number}`); |
37 | | - core.setOutput('pr_number', pr.number); |
38 | | - return; |
39 | | - } |
40 | | - } |
41 | | -
|
42 | | - console.log('No matching PR found for this commit'); |
43 | | - core.setOutput('pr_number', ''); |
44 | | -
|
45 | | - - name: Check PR draft status |
46 | | - id: check-pr-status |
47 | | - if: steps.find-pr.outputs.pr_number != '' |
48 | | - uses: actions/github-script@v7 |
49 | | - with: |
50 | | - script: | |
51 | | - const prNumber = parseInt('${{ steps.find-pr.outputs.pr_number }}'); |
52 | | - if (!prNumber) { |
53 | | - console.log('No PR number found, skipping UI tests'); |
54 | | - core.setOutput('should_run', 'false'); |
55 | | - return; |
56 | | - } |
57 | | -
|
58 | | - const { data: pr } = await github.rest.pulls.get({ |
59 | | - owner: context.repo.owner, |
60 | | - repo: context.repo.repo, |
61 | | - pull_number: prNumber |
62 | | - }); |
63 | | -
|
64 | | - const shouldRun = !pr.draft; |
65 | | - console.log(`PR #${prNumber} draft status: ${pr.draft}`); |
66 | | - console.log(`Should run UI tests: ${shouldRun}`); |
67 | | -
|
68 | | - core.setOutput('should_run', shouldRun.toString()); |
69 | 13 |
|
70 | 14 | ui-tests: |
71 | | - needs: check-conditions |
72 | | - if: ${{ needs.check-conditions.outputs.should_run == 'true' }} |
73 | 15 | runs-on: ubuntu-latest |
74 | 16 |
|
75 | 17 | steps: |
|
0 commit comments