File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -59,11 +59,20 @@ runs:
5959 command_prefix="/home/$USERNAME/runner-scripts/run.sh"
6060 fi
6161
62- # Fetch the hashes (without checking out the code)
62+ # Fetch hash of main branch
6363 _hash_main=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
6464 "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.base_ref }}" | jq -r '.sha')
65+
66+ # Fetch hash of feature branch (via PR number, also works for branches from forks)
67+ pr_details=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
68+ "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}")
69+ # Extract the repository and ref (branch name)
70+ source_repo=$(echo "$pr_details" | jq -r '.head.repo.full_name')
71+ branch_name=$(echo "$pr_details" | jq -r '.head.ref')
72+ # Get the latest commit hash from the source repository
6573 _hash_feature=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
66- "https://api.github.com/repos/${{ github.repository }}/commits/${{ github.head_ref }}" | jq -r '.sha')
74+ "https://api.github.com/repos/$source_repo/commits/$branch_name" | jq -r '.sha')
75+
6776 echo "Main branch (${{ github.base_ref }}) hash: $_hash_main"
6877 echo "Feature branch (${{ github.head_ref }}) hash: $_hash_feature"
6978
You can’t perform that action at this time.
0 commit comments