15
15
type : string
16
16
target_branch :
17
17
description : ' Target branch to checkout'
18
- required : false
19
- default : ' '
18
+ required : true
20
19
type : string
21
20
22
21
jobs :
44
43
- uses : actions/checkout@v4
45
44
with :
46
45
submodules : recursive
47
- repository : ${{ github.event.inputs.target_repository || github.repository }}
48
- ref : ${{ github.event.inputs.target_branch || github.ref }}
49
46
- name : echo host build params
50
47
run : etc/ci/describe-system-config.sh
51
48
- name : echo container build params
@@ -63,25 +60,33 @@ jobs:
63
60
GH_TOKEN : ${{ github.token }}
64
61
run : |
65
62
# Get the current branch name
66
- CURRENT_BRANCH=${{ github.event.inputs.target_branch || github.ref }}
63
+ CURRENT_BRANCH=${{ github.event.inputs.target_branch }}
67
64
echo "Current branch: $CURRENT_BRANCH"
68
65
69
66
# Check if this is a PR
70
67
# Check if this branch has an associated PR
71
68
PR_NUMBER=$(gh pr list --repo mit-plv/fiat-crypto --head $CURRENT_BRANCH --json number --jq '.[0].number')
72
- git remote add upstream https://github.com/mit-plv/fiat-crypto.git
69
+ # Add remote for target repository if specified
70
+ if [[ -n "${{ github.event.inputs.target_repository }}" && "${{ github.event.inputs.target_repository }}" != "${{ github.repository }}" ]]; then
71
+ echo "Adding remote for target repository: ${{ github.event.inputs.target_repository }}"
72
+ git remote add target_repo "https://github.com/${{ github.event.inputs.target_repository }}.git"
73
+ git checkout -b $CURRENT_BRANCH target_repo/$CURRENT_BRANCH
74
+ else
75
+ git checkout -b $CURRENT_BRANCH origin/$CURRENT_BRANCH
76
+ fi
73
77
if [[ -n "$PR_NUMBER" ]]; then
74
78
# Get the base branch from the PR
75
79
BASE_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName --jq '.baseRefName')
76
80
echo "This branch has PR #$PR_NUMBER from $CURRENT_BRANCH to $BASE_BRANCH"
77
81
# Get the merge-base of the base branch and current commit
78
- git fetch upstream $BASE_BRANCH
79
- BASE_SHA=$(git merge-base upstream/$BASE_BRANCH $GITHUB_SHA)
82
+ git fetch origin $BASE_BRANCH
83
+ BASE_SHA=$(git merge-base target_repo/$BASE_BRANCH $CURRENT_BRANCH)
84
+
80
85
else
81
86
# For non-PRs, use merge-base of current branch and master as base_sha
82
87
echo "This is not a PR, using merge-base with master"
83
- git fetch upstream master
84
- BASE_SHA=$(git merge-base upstream/ master $GITHUB_SHA )
88
+ git fetch origin master
89
+ BASE_SHA=$(git merge-base master $CURRENT_BRANCH )
85
90
fi
86
91
87
92
echo "Using base SHA: $BASE_SHA"
0 commit comments