Skip to content

Commit 58bf3e5

Browse files
committed
Check submodules
1 parent 71ea60f commit 58bf3e5

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Check submodules
2+
3+
on:
4+
pull_request:
5+
6+
# cancel in-progress runs on new commits to same PR (gitub.event.number)
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
9+
cancel-in-progress: true
10+
11+
permissions:
12+
contents: read # to fetch code (actions/checkout)
13+
14+
jobs:
15+
checks:
16+
timeout-minutes: 20
17+
18+
environment:
19+
name: development
20+
21+
env:
22+
DATABASE_URL: postgres://
23+
AUTH_SECRET: test
24+
25+
runs-on: ubuntu-24.04-arm
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
31+
32+
- uses: ./.github/actions/submodules-checkout
33+
with:
34+
submodules-ssh-key: ${{ secrets.PRIVATE_GITHUB_DEPLOY_TOKEN }}
35+
36+
- name: Check if any submodule branch matches github.ref_name
37+
run: |
38+
# Get the current branch or tag name
39+
REF_NAME="${{ github.ref_name }}"
40+
41+
# List all submodule paths
42+
SUBMODULES=$(git submodule status | awk '{print $2}')
43+
44+
# Check each submodule's branch
45+
for SUBMODULE in $SUBMODULES; do
46+
echo "Checking submodule: $SUBMODULE"
47+
(
48+
cd "$SUBMODULE"
49+
# Get the current branch of the submodule
50+
SUBMODULE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
51+
echo "Submodule branch: $SUBMODULE_BRANCH"
52+
53+
# Compare the submodule branch to the ref_name
54+
if [ "$SUBMODULE_BRANCH" = "$REF_NAME" ]; then
55+
echo "::error::Submodule '$SUBMODULE' is on branch '$SUBMODULE_BRANCH', which matches the current ref '$REF_NAME'."
56+
exit 1
57+
fi
58+
)
59+
if [ $? -ne 0 ]; then
60+
exit 1 # Fail the workflow if any submodule branch matches
61+
fi
62+
done
63+
64+
echo "No submodule is on the same branch as the current ref '$REF_NAME'."

0 commit comments

Comments
 (0)