This repository was archived by the owner on Jan 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +69
-22
lines changed
Expand file tree Collapse file tree 5 files changed +69
-22
lines changed Original file line number Diff line number Diff line change 1+ name : Get last run status for workflow
2+ description : Get last run status for workflow
3+ inputs :
4+ workflow :
5+ description : Workflow id to check status of
6+ required : false
7+ default : main.yml
8+ files :
9+ description : Check if the files changed
10+ required : true
11+ outputs :
12+ proceed :
13+ description : Should proceed running steps
14+ value : ${{ steps.changed_files.outputs.any_changed == 'true' || steps.last_status.outputs.result != 'true' }}
15+ runs :
16+ using : composite
17+ steps :
18+ - name : Check change in files
19+ id : changed_files
20+ uses :
tj-actions/[email protected] 21+ with :
22+ files : ${{ inputs.files }}
23+
24+ - name : Get last run
25+ if : steps.changed_files.outputs.any_changed != 'true'
26+ id : last_status
27+ 28+ with :
29+ result-encoding : json
30+ script : |
31+ const { GITHUB_REF_NAME, WORKFLOW } = process.env;
32+ core.startGroup(`Checking last status for workflow \`${WORKFLOW}\` for branch \`${GITHUB_REF_NAME}\``);
33+ const result = await github.rest.actions.listWorkflowRuns({
34+ owner: context.repo.owner,
35+ repo: context.repo.repo,
36+ workflow_id: WORKFLOW,
37+ branch: GITHUB_REF_NAME,
38+ per_page: 2,
39+ page: 1
40+ });
41+ core.info(JSON.stringify(result));
42+ core.endGroup();
43+ const success = (result.data.workflow_runs[0]?.status === 'completed') ||
44+ (result.data.workflow_runs[1]?.status === 'completed');
45+ return success;
46+ env :
47+ WORKFLOW : ${{ inputs.workflow }}
Original file line number Diff line number Diff line change @@ -26,28 +26,28 @@ jobs:
2626 default_bump : false
2727 dry_run : true
2828
29- - name : Check change in documentation
30- id : changed_doc
29+ - name : Check should proceed running steps
3130 if : steps.check_version_bump.outputs.release_type == ''
32- uses :
tj-actions/[email protected] 31+ id : precondition
32+ uses : ./.github/actions/condition
3333 with :
3434 files : |
3535 Sources/**/*
3636 Package*.swift
3737 .github/workflows/ci.yml
3838
3939 - name : Setup repository
40- if : steps.changed_doc .outputs.any_changed == 'true'
40+ if : steps.precondition .outputs.proceed == 'true'
4141 uses : ./.github/actions/setup
4242
4343 - name : Build package documentation
44- if : steps.changed_doc .outputs.any_changed == 'true'
44+ if : steps.precondition .outputs.proceed == 'true'
4545 run : |
4646 npm run build
4747 npm run serve-doc
4848
4949 - name : Update GitHub Pages
50- if : steps.changed_doc .outputs.any_changed == 'true'
50+ if : steps.precondition .outputs.proceed == 'true'
51515252 with :
5353 branch : gh-pages
Original file line number Diff line number Diff line change 1313 - name : Checkout repository
1414 uses : actions/checkout@v3
1515
16- - name : Check change in source files
17- id : changed_source
18- uses :
tj-actions/[email protected] 16+ - name : Check should proceed running steps
17+ id : precondition
18+ uses : ./.github/actions/condition
1919 with :
2020 files : |
2121 Sources/**/*.swift
2525 .github/workflows/cocoapods.yml
2626
2727 - name : Setup repository
28- if : steps.changed_source .outputs.any_changed == 'true'
28+ if : steps.precondition .outputs.proceed == 'true'
2929 uses : ./.github/actions/setup
3030
3131 - name : Run tests
32- if : steps.changed_source .outputs.any_changed == 'true'
32+ if : steps.precondition .outputs.proceed == 'true'
3333 run : npm run pod-lint
Original file line number Diff line number Diff line change 1919 - name : Checkout repository
2020 uses : actions/checkout@v3
2121
22- - name : Check change in source files
23- id : changed_source
24- uses :
tj-actions/[email protected] 22+ - name : Check should proceed running steps
23+ id : precondition
24+ uses : ./.github/actions/condition
2525 with :
2626 files : |
2727 Sources/**/*.swift
@@ -31,18 +31,18 @@ jobs:
3131 .github/workflows/swift-package.yml
3232
3333 - name : Setup repository
34- if : steps.changed_source .outputs.any_changed == 'true'
34+ if : steps.precondition .outputs.proceed == 'true'
3535 uses : ./.github/actions/setup
3636 with :
3737 swift : ${{ matrix.swift }}
3838
3939 - name : Run tests
40- if : steps.changed_source .outputs.any_changed == 'true'
40+ if : steps.precondition .outputs.proceed == 'true'
4141 run : npm run test
4242
4343 - name : Swift Coverage Report
4444 if : |
45- steps.changed_source .outputs.any_changed == 'true' &&
45+ steps.precondition .outputs.proceed == 'true' &&
4646 matrix.swift == '5.6' &&
4747 github.event_name == 'push'
48485252
5353 - name : Codecov upload
5454 if : |
55- steps.changed_source .outputs.any_changed == 'true' &&
55+ steps.precondition .outputs.proceed == 'true' &&
5656 matrix.swift == '5.6' &&
5757 github.event_name == 'push'
5858
Original file line number Diff line number Diff line change 1616 - name : Checkout repository
1717 uses : actions/checkout@v3
1818
19- - name : Check change in source files
20- id : changed_source
21- uses :
tj-actions/[email protected] 19+ - name : Check should proceed running steps
20+ id : precondition
21+ uses : ./.github/actions/condition
2222 with :
2323 files : |
2424 Sources/**/*.swift
2727 .github/workflows/xcode.yml
2828
2929 - name : Build with Xcode
30- if : steps.changed_source .outputs.any_changed == 'true'
30+ if : steps.precondition .outputs.proceed == 'true'
3131 uses : mxcl/xcodebuild@v1
3232 with :
3333 xcode : ' 11.3.1'
You can’t perform that action at this time.
0 commit comments