-
Notifications
You must be signed in to change notification settings - Fork 799
67 lines (52 loc) · 2.03 KB
/
check-submodules.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Check submodules
on:
pull_request:
# cancel in-progress runs on new commits to same PR (gitub.event.number)
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
checks:
timeout-minutes: 20
environment:
name: development
env:
DATABASE_URL: postgres://
AUTH_SECRET: test
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: ./.github/actions/submodules-checkout
with:
submodules-ssh-key: ${{ secrets.PRIVATE_GITHUB_DEPLOY_TOKEN }}
- name: Check if any submodule branch matches github.ref_name
run: |
echo "C ${{ github.workflow }}-${{ github.event.number || github.sha }}"
# Get the current branch or tag name
REF_NAME="${{ github.event.pull_request.head.ref || github.ref_name }}"
echo "Branch is:" $REF_NAME
# List all submodule paths
SUBMODULES=$(git submodule status | awk '{print $2}')
# Check each submodule's branch
for SUBMODULE in $SUBMODULES; do
echo "Checking submodule: $SUBMODULE"
(
cd "$SUBMODULE"
# Get the current branch of the submodule
SUBMODULE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Submodule branch: $SUBMODULE_BRANCH"
# Compare the submodule branch to the ref_name
if [ "$SUBMODULE_BRANCH" = "$REF_NAME" ]; then
echo "::error::Submodule '$SUBMODULE' is on branch '$SUBMODULE_BRANCH', which matches the current ref '$REF_NAME'."
exit 1
fi
)
if [ $? -ne 0 ]; then
exit 1 # Fail the workflow if any submodule branch matches
fi
done
echo "No submodule is on the same branch as the current ref '$REF_NAME'."