-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (41 loc) · 1.61 KB
/
pre_ci.yml
File metadata and controls
49 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# When a branch is used to open a PR in the branch's own repository, GitHub will
# trigger 'on: push' workflows against the head commit of the PR, and trigger
# 'on: pull_request' workflows against a merge commit between the head commit
# and the PR's base branch (typically master).
#
# Often times those 2 sets of jobs end up running against identical trees. This
# is the case if there have been no commits on the base branch since when the
# PR's head branch was forked from the base branch.
#
# The code below detects this common scenario and provides a way to bypass CI
# from running redundantly on the merge commit.
name: pre_ci
on:
workflow_call:
outputs:
continue:
description: "whether to execute the workflow"
value: ${{jobs.pre_ci.outputs.continue}}
permissions:
contents: read
jobs:
pre_ci:
runs-on: ubuntu-latest
outputs:
continue: ${{steps.decision.outputs.continue}}
steps:
- id: is_local_pull_request
run: echo value=true >> $GITHUB_OUTPUT
if: github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
- uses: actions/checkout@v3
with:
fetch-depth: 2
if: steps.is_local_pull_request.outputs.value
- id: is_noop_merge
run: if git diff HEAD^2 --quiet; then echo value=true >> $GITHUB_OUTPUT; fi
if: steps.is_local_pull_request.outputs.value
- id: decision
run: echo continue=true >> $GITHUB_OUTPUT
if: |
!steps.is_local_pull_request.outputs.value || !steps.is_noop_merge.outputs.value