ci(refactor): compute before/after references in parent workflow
This commit is contained in:
parent
124c5d94e5
commit
4151fe5045
|
@ -154,6 +154,8 @@ jobs:
|
|||
with:
|
||||
runner: ${{ needs.sanity-checks.outputs.runner }}
|
||||
builder: ${{ needs.sanity-checks.outputs.builder }}
|
||||
before_ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
|
||||
after_ref: ${{ github.sha }}
|
||||
|
||||
run_test_cases:
|
||||
needs:
|
||||
|
|
|
@ -166,6 +166,8 @@ jobs:
|
|||
with:
|
||||
runner: ${{ needs.sanity-checks.outputs.runner }}
|
||||
builder: ${{ needs.sanity-checks.outputs.builder }}
|
||||
before_ref: ${{ github.event.before }}
|
||||
after_ref: ${{ github.sha }}
|
||||
|
||||
run_test_cases:
|
||||
if: needs.prepare.outputs.release != 'true'
|
||||
|
|
|
@ -16,6 +16,12 @@ on:
|
|||
builder:
|
||||
required: true
|
||||
type: string
|
||||
before_ref:
|
||||
required: true
|
||||
type: string
|
||||
after_ref:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
IS_CI: "yes"
|
||||
|
@ -34,20 +40,12 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
- name: run
|
||||
env:
|
||||
BEFORE_REF: ${{ inputs.before_ref }}
|
||||
AFTER_REF: ${{ inputs.after_ref }}
|
||||
run: |
|
||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||
echo "git diff base: $GITHUB_BASE_REF"
|
||||
if [[ "$GITHUB_BASE_REF" =~ [0-9a-f]{8,40} ]]; then
|
||||
# base is a commit sha1
|
||||
compare_base="$GITHUB_BASE_REF"
|
||||
else
|
||||
repo="${GITHUB_REPOSITORY}"
|
||||
git remote -v
|
||||
remote="$(git remote -v | grep -E "github\.com(:|/)$repo((\.git)|(\s))" | grep fetch | awk '{print $1}')"
|
||||
git fetch "$remote" "$GITHUB_BASE_REF"
|
||||
compare_base="$remote/$GITHUB_BASE_REF"
|
||||
fi
|
||||
changed_files="$(git diff --name-only ${compare_base} HEAD apps/emqx)"
|
||||
changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)"
|
||||
if [ "$changed_files" = '' ]; then
|
||||
echo "nothing changed in apps/emqx, ignored."
|
||||
exit 0
|
||||
|
|
Loading…
Reference in New Issue