mirror of
https://github.com/super-linter/super-linter.git
synced 2024-11-21 21:50:59 -05:00
3558649572
Some checks failed
Build and Test / Set build metadata (push) Has been cancelled
Build and Test / Build test suite matrix (push) Has been cancelled
Build and Test / preview-release-notes (push) Has been cancelled
Lint commit / commitlint (push) Has been cancelled
Build and Test / Build and Test (push) Has been cancelled
Build and Test / Test the Super-linter GitHub Action (push) Has been cancelled
Build and Test / Run test cases (push) Has been cancelled
Build and Test / Check if all the tests passed (push) Has been cancelled
When a "push tag" event triggers a GitHub Actions workflow, the "commits" array in the event payload is empty, so the commit count in this case (GITHUB_PUSH_COMMIT_COUNT) is 0. In the particular case of a tag pointing to a merge commit, adjust the logic that initializes GITHUB_PUSH_COMMIT_COUNT. Close #6193
32 lines
1.1 KiB
Bash
Executable file
32 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Push event payload ref: https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
|
|
|
|
function GetGithubPushEventCommitCount() {
|
|
local GITHUB_EVENT_FILE_PATH
|
|
GITHUB_EVENT_FILE_PATH="${1}"
|
|
local GITHUB_PUSH_COMMIT_COUNT
|
|
|
|
if ! GITHUB_PUSH_COMMIT_COUNT=$(jq -r '.commits | length' <"${GITHUB_EVENT_FILE_PATH}"); then
|
|
fatal "Failed to initialize GITHUB_PUSH_COMMIT_COUNT for a push event. Output: ${GITHUB_PUSH_COMMIT_COUNT}"
|
|
fi
|
|
|
|
if IsUnsignedInteger "${GITHUB_PUSH_COMMIT_COUNT}" && [ -n "${GITHUB_PUSH_COMMIT_COUNT}" ]; then
|
|
echo "${GITHUB_PUSH_COMMIT_COUNT}"
|
|
return 0
|
|
else
|
|
fatal "GITHUB_PUSH_COMMIT_COUNT is not an integer: ${GITHUB_PUSH_COMMIT_COUNT}"
|
|
fi
|
|
}
|
|
|
|
function GetGithubRepositoryDefaultBranch() {
|
|
local GITHUB_EVENT_FILE_PATH
|
|
GITHUB_EVENT_FILE_PATH="${1}"
|
|
local GITHUB_REPOSITORY_DEFAULT_BRANCH
|
|
|
|
if ! GITHUB_REPOSITORY_DEFAULT_BRANCH=$(jq -r '.repository.default_branch' <"${GITHUB_EVENT_FILE_PATH}"); then
|
|
fatal "Failed to initialize GITHUB_REPOSITORY_DEFAULT_BRANCH. Output: ${GITHUB_REPOSITORY_DEFAULT_BRANCH}"
|
|
fi
|
|
|
|
echo "${GITHUB_REPOSITORY_DEFAULT_BRANCH}"
|
|
}
|