ci(refactor): compute before/after references in parent workflow
This commit is contained in:
parent
124c5d94e5
commit
4151fe5045
|
@ -154,6 +154,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
runner: ${{ needs.sanity-checks.outputs.runner }}
|
runner: ${{ needs.sanity-checks.outputs.runner }}
|
||||||
builder: ${{ needs.sanity-checks.outputs.builder }}
|
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:
|
run_test_cases:
|
||||||
needs:
|
needs:
|
||||||
|
|
|
@ -166,6 +166,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
runner: ${{ needs.sanity-checks.outputs.runner }}
|
runner: ${{ needs.sanity-checks.outputs.runner }}
|
||||||
builder: ${{ needs.sanity-checks.outputs.builder }}
|
builder: ${{ needs.sanity-checks.outputs.builder }}
|
||||||
|
before_ref: ${{ github.event.before }}
|
||||||
|
after_ref: ${{ github.sha }}
|
||||||
|
|
||||||
run_test_cases:
|
run_test_cases:
|
||||||
if: needs.prepare.outputs.release != 'true'
|
if: needs.prepare.outputs.release != 'true'
|
||||||
|
|
|
@ -16,6 +16,12 @@ on:
|
||||||
builder:
|
builder:
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
before_ref:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
after_ref:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
env:
|
env:
|
||||||
IS_CI: "yes"
|
IS_CI: "yes"
|
||||||
|
@ -34,20 +40,12 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: run
|
- name: run
|
||||||
|
env:
|
||||||
|
BEFORE_REF: ${{ inputs.before_ref }}
|
||||||
|
AFTER_REF: ${{ inputs.after_ref }}
|
||||||
run: |
|
run: |
|
||||||
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
echo "git diff base: $GITHUB_BASE_REF"
|
changed_files="$(git diff --name-only ${BEFORE_REF} ${AFTER_REF} apps/emqx)"
|
||||||
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)"
|
|
||||||
if [ "$changed_files" = '' ]; then
|
if [ "$changed_files" = '' ]; then
|
||||||
echo "nothing changed in apps/emqx, ignored."
|
echo "nothing changed in apps/emqx, ignored."
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue