-
Notifications
You must be signed in to change notification settings - Fork 3.7k
51 lines (43 loc) · 1.22 KB
/
check-minimum-revision.yaml
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
50
51
name: "Check Minimum Revision"
on:
workflow_call:
inputs:
GIT_SHA:
required: true
type: string
workflow_dispatch:
inputs:
GIT_SHA:
required: true
type: string
env:
GIT_SHA: ${{ inputs.GIT_SHA }}
MINIMUM_REVISION: ${{ secrets.MINIMUM_REVISION }}
jobs:
check-minimum-revision:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.GIT_SHA }}
fetch-depth: 1000
- name: Check merge base is new enough
id: check-merge-base
run: |
set -ex
if [ -z "$MINIMUM_REVISION" ]; then
echo "Skipping check"
exit 0
fi
git fetch origin main
set +e
git merge-base \
--is-ancestor "$MINIMUM_REVISION" "${{ env.GIT_SHA }}"
FAILED=$?
set -e
echo "FAIL_MERGE_BASE=${FAILED}" >> $GITHUB_OUTPUT
MERGE_BASE="$(git merge-base origin/main ${{ env.GIT_SHA }})"
if [[ $FAILED == 1 ]]; then
echo "Your merge base $MERGE_BASE is too old" | tee fail-merge-base.txt
echo "Please rebase on or past $MINIMUM_REVISION" | tee -a fail-merge-base.txt
fi