|
9 | 9 | ci-config:
|
10 | 10 | runs-on: ubuntu-latest
|
11 | 11 | outputs:
|
12 |
| - enabled: ${{ steps.check-ref.outputs.enabled }} |
| 12 | + enabled: ${{ steps.check-ref.outputs.enabled }}${{ steps.skip-if-redundant.outputs.enabled }} |
13 | 13 | steps:
|
14 | 14 | - name: try to clone ci-config branch
|
15 | 15 | run: |
|
|
34 | 34 | enabled=no
|
35 | 35 | fi
|
36 | 36 | echo "::set-output name=enabled::$enabled"
|
| 37 | + - name: skip if the commit or tree was already tested |
| 38 | + id: skip-if-redundant |
| 39 | + uses: actions/github-script@v3 |
| 40 | + if: steps.check-ref.outputs.enabled == 'yes' |
| 41 | + with: |
| 42 | + github-token: ${{secrets.GITHUB_TOKEN}} |
| 43 | + script: | |
| 44 | + // Figure out workflow ID, commit and tree |
| 45 | + const { data: run } = await github.actions.getWorkflowRun({ |
| 46 | + owner: context.repo.owner, |
| 47 | + repo: context.repo.repo, |
| 48 | + run_id: context.runId, |
| 49 | + }); |
| 50 | + const workflow_id = run.workflow_id; |
| 51 | + const head_sha = run.head_sha; |
| 52 | + const tree_id = run.head_commit.tree_id; |
| 53 | +
|
| 54 | + // See whether there is a successful run for that commit or tree |
| 55 | + const { data: runs } = await github.actions.listWorkflowRuns({ |
| 56 | + owner: context.repo.owner, |
| 57 | + repo: context.repo.repo, |
| 58 | + per_page: 500, |
| 59 | + status: 'success', |
| 60 | + workflow_id, |
| 61 | + }); |
| 62 | + for (const run of runs.workflow_runs) { |
| 63 | + if (head_sha === run.head_sha) { |
| 64 | + core.warning(`Successful run for the commit ${head_sha}: ${run.html_url}`); |
| 65 | + core.setOutput('enabled', ' but skip'); |
| 66 | + break; |
| 67 | + } |
| 68 | + if (tree_id === run.head_commit.tree_id) { |
| 69 | + core.warning(`Successful run for the tree ${tree_id}: ${run.html_url}`); |
| 70 | + core.setOutput('enabled', ' but skip'); |
| 71 | + break; |
| 72 | + } |
| 73 | + } |
37 | 74 |
|
38 | 75 | windows-build:
|
39 | 76 | needs: ci-config
|
|
0 commit comments