Skip to content

Commit 5574923

Browse files
authored
misc: only run scheduled publish job if there are new commits (GoogleChrome#14145)
1 parent b7efa1d commit 5574923

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

.github/workflows/publish.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,27 @@ on:
55
workflow_dispatch: {}
66

77
jobs:
8+
check_date:
9+
runs-on: ubuntu-latest
10+
outputs:
11+
should_run: ${{ steps.should_run.outputs.should_run }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: print latest_commit
15+
run: echo ${{ github.sha }}
16+
17+
- id: should_run
18+
continue-on-error: true
19+
if: ${{ github.event_name == 'schedule' }}
20+
run: test -z $(git rev-list --after="1 day" ${{ github.sha }}) && echo "::set-output name=should_run::false"
21+
822
publish:
9-
# Prevent forks from running this job.
10-
if: (github.event_name == 'schedule' && github.repository == 'GoogleChrome/lighthouse') || (github.event_name != 'schedule')
23+
# Prevent scheduled job from running if...
24+
# 1) this is a fork
25+
# 2) there has not been a change in the last day
26+
if: |
27+
github.event_name != 'schedule' ||
28+
(github.repository == 'GoogleChrome/lighthouse' && ${{ needs.check_date.outputs.should_run != 'false' }})
1129
runs-on: ubuntu-latest
1230
steps:
1331
- uses: actions/checkout@v1

0 commit comments

Comments
 (0)