Skip to content

Commit 8296bd5

Browse files
committed
ci: specify refs
1 parent 49d3c38 commit 8296bd5

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

.github/workflows/metadata.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ on:
44
pull_request_review:
55
types: [submitted]
66
workflow_dispatch:
7+
inputs:
8+
base_ref:
9+
description: "Base branch reference (e.g., main)"
10+
required: true
11+
head_ref:
12+
description: "Head branch reference (e.g., feature-branch)"
13+
required: true
714

815
jobs:
916
metadata:
@@ -19,15 +26,27 @@ jobs:
1926
with:
2027
submodules: false
2128

29+
- name: Set Base and Head Refs
30+
run: |
31+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
32+
BASE_REF="${{ github.event.inputs.base_ref }}"
33+
HEAD_REF="${{ github.event.inputs.head_ref }}"
34+
else
35+
BASE_REF="${{ github.event.pull_request.base.sha }}"
36+
HEAD_REF="${{ github.event.pull_request.head.sha }}"
37+
fi
38+
echo "BASE_REF=$BASE_REF" >> $GITHUB_ENV
39+
echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
40+
2241
- name: Fetch Base Branch
2342
run: |
2443
# Fetch all history for the base branch and PR head
25-
git fetch origin ${{ github.base_ref }} --depth=1
26-
git fetch origin ${{ github.head_ref }} --depth=1
44+
git fetch origin ${BASE_REF} --depth=1
45+
git fetch origin ${HEAD_REF} --depth=1
2746
2847
- name: Detect Added Submodules
2948
run: |
30-
ADDED_SUBMODULES=$(git diff --submodule main..HEAD | grep '^Submodule' | awk '{ print $2 }')
49+
ADDED_SUBMODULES=$(git diff --submodule ${BASE_REF}..${HEAD_REF} | grep '^Submodule' | awk '{ print $2 }')
3150
echo "Added submodules: $ADDED_SUBMODULES"
3251
echo "ADDED_SUBMODULES=$ADDED_SUBMODULES" >> $GITHUB_ENV
3352

0 commit comments

Comments
 (0)