Skip to content

Commit bb7a906

Browse files
committed
Use HEAD instead of GITHUB_SHA to diff master and PR
- Using "${GITHUB_SHA}" to point to the pull request commit does not work when the pull request comes from a fork. The incorrect SHA leads to the diff being incorrect, which leads to validation errors. Using HEAD eliminates these problems, diffing the correct states.
1 parent 3439f9f commit bb7a906

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

.github/workflows/ci.yaml

+6-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ jobs:
3434
echo
3535
3636
echo "Obtaining PR file change diff:"
37+
echo "BASE: ${BASE}"
3738
echo
38-
git --no-pager diff --name-status origin/"${BASE}" "${GITHUB_SHA}" > "${GITHUB_SHA}.diff"
39-
cat "${GITHUB_SHA}.diff"
39+
git --no-pager diff --name-status origin/"${BASE}" HEAD > "HEAD.diff"
40+
cat "HEAD.diff"
4041
echo
4142
4243
rm -f fail-location fail-filename || :
4344
echo "Validating all changed PR files are in the ${LOCATION} directory:"
4445
echo
45-
awk '{print $2}' "${GITHUB_SHA}.diff" | sort \
46+
awk '{print $2}' "HEAD.diff" | sort \
4647
| xargs -I{} bash -c '[[ {} =~ ^${LOCATION}/.*$ ]] && echo "pass: {}" || { echo "FAIL: {}"; touch fail-location; }'
4748
echo
4849
@@ -78,6 +79,6 @@ jobs:
7879
echo "Running the metadata validation tool on this PR:"
7980
echo
8081
VALIDATOR="./token-metadata-creator validate"
81-
awk '/^M/ {print $2}' "pull-request/${GITHUB_SHA}.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 master/$2 pull-request/$2" && $1 master/$2 pull-request/$2' -- "$VALIDATOR"
82-
awk '/^A/ {print $2}' "pull-request/${GITHUB_SHA}.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 pull-request/$2" && $1 pull-request/$2' -- "$VALIDATOR"
82+
awk '/^M/ {print $2}' "pull-request/HEAD.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 master/$2 pull-request/$2" && $1 master/$2 pull-request/$2' -- "$VALIDATOR"
83+
awk '/^A/ {print $2}' "pull-request/HEAD.diff" | xargs --no-run-if-empty -- bash -c 'echo "$1 pull-request/$2" && $1 pull-request/$2' -- "$VALIDATOR"
8384
echo

0 commit comments

Comments
 (0)