Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
150 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
currentDir=$(pwd) | ||
. $currentDir/.github/include/function.sh | ||
|
||
echo -e "------------ The script api_test.sh is running ------------" | ||
echo -e "1. Print the variables" | ||
PrintEnv | ||
|
||
if [ "${API_TEST_SWITCH}" == "" ] || [ "${API_TEST_SWITCH}" == "off" ] ; then | ||
echo -e "Because you turn off the switch, so skip api_test.sh" | ||
exit 0 | ||
fi | ||
EveryStageCommonOperation | ||
|
||
eval $API_TEST_TRIGGER_CMD | ||
if [ $? -ne 0 ]; then | ||
FAILURE_REASON="run API Test failed" | ||
SendFailureNotice | ||
exit 1 | ||
if [ "${API_TEST_TRIGGER_CMD}" != "" ]; then | ||
eval $API_TEST_TRIGGER_CMD | ||
if [ $? -ne 0 ]; then | ||
FAILURE_REASON="run API Test failed" | ||
SendFailureNotice | ||
exit 1 | ||
else | ||
echo -e "run API Test success" | ||
fi | ||
else | ||
echo -e "run API Test success" | ||
echo -e "No variable configurations for api test" | ||
fi | ||
|
||
echo -e "------------ The script api_test.sh is stopped ------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
# Print the environment variables. | ||
PrintEnv(){ | ||
echo -e "cat /proc/version="$(cat /proc/version) | ||
echo -e "CI_BUILDS_DIR=${CI_BUILDS_DIR}" | ||
echo -e "pwd="$(pwd) | ||
echo -e "ls="$(ls) | ||
echo -e "cat /proc/version="$(cat /proc/version) | ||
echo -e "CI_BUILDS_DIR=${CI_BUILDS_DIR}" | ||
echo -e "pwd="$(pwd) | ||
echo -e "ls="$(ls) | ||
} | ||
|
||
# Actions performed by each task | ||
EveryStageCommonOperation(){ | ||
echo -e "[The following are common operations for each task]" | ||
echo -e "[- Print the variables]" | ||
PrintEnv | ||
echo -e "[The above are common operations for each task]" | ||
} | ||
|
||
# Send the failure notice. | ||
SendFailureNotice(){ | ||
if [ "${CI_COMMIT_REF_NAME}" == "${CI_DEFAULT_BRANCH}" ]; then | ||
actionName="Request to merge ${CI_COMMIT_REF_NAME}" | ||
elif [ "${CI_COMMIT_REF_NAME}" == "test" ]; then | ||
actionName="Request to merge test" | ||
else | ||
actionName="Commit to ${CI_COMMIT_REF_NAME}" | ||
fi | ||
if [ "${GITHUB_REF_NAME}" == "main" ] || [ "${GITHUB_REF_NAME}" == "master" ] ; then | ||
actionName="Request to merge ${GITHUB_REF_NAME}" | ||
elif [ "${GITHUB_REF_NAME}" == "test" ]; then | ||
actionName="Request to merge test" | ||
else | ||
actionName="Commit to ${GITHUB_REF_NAME}" | ||
fi | ||
|
||
MESSAGE="【${DING_KEYWORD}】CI/CD Failed Notice | ||
Operation: ${actionName} | ||
Project: ${CI_PROJECT_NAME} | ||
Branch: ${CI_COMMIT_REF_NAME} | ||
Operator: ${GITLAB_USER_EMAIL} | ||
Reason: ${FAILURE_REASON} | ||
More: ${CI_PIPELINE_URL} | ||
made by CIManager | ||
" | ||
if [ "${DING_NOTICE_SWITCH}" == "on" ] && [ "${DING_ACCESS_TOKEN}" != "" ] ; then | ||
curl -H 'Content-type: application/json' -d "{\"msgtype\":\"text\", \"text\": {\"content\":\"${MESSAGE}\"}}" "https://oapi.dingtalk.com/robot/send?access_token=${DING_ACCESS_TOKEN}" | ||
else | ||
echo $MESSAGE | ||
fi | ||
MESSAGE="【${DING_KEYWORD}】CI/CD Failed Notice | ||
Operation: ${actionName} | ||
Project: ${GITHUB_REPOSITORY} | ||
Branch: ${GITHUB_REF_NAME} | ||
Reason: ${FAILURE_REASON} | ||
More: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} | ||
made by CIManager | ||
" | ||
if [ "${DING_NOTICE_SWITCH}" == "on" ] && [ "${DING_ACCESS_TOKEN}" != "" ] ; then | ||
curl -H 'Content-type: application/json' -d "{\"msgtype\":\"text\", \"text\": {\"content\":\"${MESSAGE}\"}}" "https://oapi.dingtalk.com/robot/send?access_token=${DING_ACCESS_TOKEN}" | ||
else | ||
echo $MESSAGE | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,55 @@ | ||
currentDir=$(pwd) | ||
. $currentDir/.github/include/function.sh | ||
|
||
echo -e "------------ The script pre_check.sh is running ------------" | ||
echo -e "1. Print the variables" | ||
PrintEnv | ||
|
||
echo -e "2. Check the must variables" | ||
EveryStageCommonOperation | ||
|
||
if [ "${DING_NOTICE_SWITCH}" == "on" ]; then | ||
if [ "${DING_ACCESS_TOKEN}" == "" ]; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables DING_ACCESS_TOKEN empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
echo -e "1. Check the must variables" | ||
|
||
# unit_test.sh | ||
if [ "${UNIT_TEST_SWITCH}" == "on" ]; then | ||
if [ "${UNIT_TEST_TRIGGER_CMD}" == "" ]; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables UNIT_TEST_TRIGGER_CMD empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
if [ "${UNIT_TEST_TRIGGER_CMD}" == "" ]; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables UNIT_TEST_TRIGGER_CMD empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# apidoc_gen.sh | ||
if [ "${APIDOC_SWITCH}" == "on" ]; then | ||
if [ "${APIDOC_TRIGGER_CMD}" == "" ] || [ "${APIDOC_FILE}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables APIDOC_TRIGGER_CMD/APIDOC_FILE empty" | ||
SendFailureNotice | ||
exit 1 | ||
elif [ "${GITHUB_HOST}" == "" ] || [ "${GITHUB_API_TOKEN}" == "" ] || [ "${PROJECT_ID}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables GITHUB_HOST/GITHUB_API_TOKEN/PROJECT_ID empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
if [ "${APIDOC_TRIGGER_CMD}" == "" ] || [ "${APIDOC_FILE}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables APIDOC_TRIGGER_CMD/APIDOC_FILE empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# local_build.sh | ||
if [ "${LOCAL_BUILD_SWITCH}" == "on" ]; then | ||
if [ "${LOCAL_BUILD_TRIGGER_CMD}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables LOCAL_BUILD_TRIGGER_CMD empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
if [ "${LOCAL_BUILD_TRIGGER_CMD}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables LOCAL_BUILD_TRIGGER_CMD empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# health_check.sh | ||
if [ "${HEALTH_CHECK_SWITCH}" == "on" ]; then | ||
if [ "${HEALTH_CHECK_TRIGGER_CMD}" == "" ] || [ "${HEALTH_CHECK_SUCCESS}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables HEALTH_CHECK_TRIGGER_CMD/HEALTH_CHECK_SUCCESS empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
if [ "${HEALTH_CHECK_TRIGGER_CMD}" == "" ] || [ "${HEALTH_CHECK_SUCCESS}" == "" ] ; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables HEALTH_CHECK_TRIGGER_CMD/HEALTH_CHECK_SUCCESS empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# include/function.sh > SendFailureNotice() | ||
if [ "${DING_NOTICE_SWITCH}" == "on" ]; then | ||
if [ "${DING_ACCESS_TOKEN}" == "" ]; then | ||
FAILURE_REASON="Failed to run pre_check.sh: the variables DING_ACCESS_TOKEN empty" | ||
SendFailureNotice | ||
exit 1 | ||
fi | ||
fi | ||
|
||
echo -e "------------ The script pre_check.sh is stopped ------------" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: github-ci | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- testing | ||
- test | ||
jobs: | ||
|
||
CIManager: | ||
runs-on: ubuntu-latest | ||
env: | ||
working-directory: .github/ | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: git clone -b testing https://github.com/wgrape/CIManager.git ; cp -an ./CIManager/. ./ ; rm -rf ./CIManager ; bash start.sh github |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.