curl -s-X POST -d'{"state": "closed"}'-H"Authorization: token $GH_PERSONAL_TOKEN" https://api.github.com/repos/PixelExperience/official_devices/pulls/$SEMAPHORE_GIT_PR_NUMBER>/dev/null
curl -s-X POST -d'{"body": "This is Pixel CI Automation Service! This PR has been closed as it has a derped devices.json and/or you are PR-ing some other file. Please recheck your PR."}'-H"Authorization: token $GH_PERSONAL_TOKEN" https://api.github.com/repos/PixelExperience/official_devices/issues/$SEMAPHORE_GIT_PR_NUMBER/comments >/dev/null
export CHANGED_FILES="$(git --no-pager diff --name-only HEAD $(git merge-base HEAD origin/master))"
fi
}
function checkLint(){
if[["$COMMIT_MESSAGE"=~ "[PIXEL-CI]"]];then
if[[-n"$SEMAPHORE_GIT_PR_NUMBER"]];then
sendMaintainers "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER has CI-Skip mechanism. It has been closed.\`"
sendAdmins "\`Official-Devices CI%0A%0AI have closed PR $SEMAPHORE_GIT_PR_NUMBER for using CI-Skip mechanism. \`%0A%0A[PR Link](https://github.com/PixelExperience/official_devices/pull/$SEMAPHORE_GIT_PR_NUMBER)"
curl -s-X POST -d'{"state": "closed"}'-H"Authorization: token $GH_PERSONAL_TOKEN" https://api.github.com/repos/PixelExperience/official_devices/pulls/$SEMAPHORE_GIT_PR_NUMBER>/dev/null
curl -s-X POST -d'{"body": "This is Pixel CI Automation Service! You attempted to skip CI on a PR, its not permitted. Reopen PR after you fix the commit message."}'-H"Authorization: token $GH_PERSONAL_TOKEN" https://api.github.com/repos/PixelExperience/official_devices/issues/$SEMAPHORE_GIT_PR_NUMBER/comments >/dev/null
sendMaintainers "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER has changed some other file.\`"
sendAdmins "\`Official-Devices CI%0A%0AI have closed PR $SEMAPHORE_GIT_PR_NUMBER due to ERROR: Mismatched Files.\`%0A%0A[PR Link](https://github.com/PixelExperience/official_devices/pull/$SEMAPHORE_GIT_PR_NUMBER)"
ALTERED_DEVICE="$(git --no-pager diff HEAD "$(git merge-base HEAD origin/master)" | grep"codename")"
if[[-z"$ALTERED_DEVICE"]];then
echo"Yay! My works took $((DIFF /60)) minute(s) and $((DIFF %60)) seconds.~"
sendAdmins "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER can be merged.\` %0A%0A${ADMINS} %0A%0A[PR Link](https://github.com/PixelExperience/official_devices/pull/$SEMAPHORE_GIT_PR_NUMBER) %0A%0A\`CI couldn't figure out which device was PR-ed\`"
sendMaintainers "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER has passed all checks. Please wait for the merge. CI can't figure out which device was PR-ed\`"
else
echo"Yay! My works took $((DIFF /60)) minute(s) and $((DIFF %60)) seconds.~"
curl -s-X GET -H"Authorization: token $GH_PERSONAL_TOKEN"-H"Accept: application/vnd.github.v3.diff" https://api.github.com/repos/PixelExperience/official_devices/pulls/$SEMAPHORE_GIT_PR_NUMBER> git-diff
sendAdmins "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER can be merged.\`%0A%0A${ADMINS}%0A%0A\`Diff sent below\`%0A%0A[PR Link](https://github.com/PixelExperience/official_devices/pull/$SEMAPHORE_GIT_PR_NUMBER)"
sendAdmins_HTML "<code>$(cat git-diff)</code>"
rm-rf git-diff
sendMaintainers "\`Official-Devices CI%0A%0APR $SEMAPHORE_GIT_PR_NUMBER has passed all checks. Please wait for merge.%0A%0ADevice PR-ed for: ${ALTERED_DEVICE}\`"
exit 0
fi
fi
fi
elif["$RESULT"-ne 0 ];then
sendAdmins "\`Official-Devices CI%0A%0ASomeone has merged a failing file. Please look in ASAP.\`%0A%0A\`Error Code: ${ERROR_CODE}\`%0A%0A\`Failed File: ${FAILED_FILE}\`%0A%0A${ADMINS}"
echo"My works took $((DIFF /60)) minute(s) and $((DIFF %60)) seconds. But its an error!"
exit 1
else
sendAdmins "\`Official-Devices CI\`%0A%0A**I am building master branch job.** %0A**Commit Point:** [${COMMIT_SMALL_HASH}](https://github.com/PixelExperience/official_devices/commit/${COMMIT_HASH})"
fi
}
function pushToGit(){
if[-z"$SEMAPHORE_GIT_PR_NUMBER"]&&[-n"$(git status -s)"];then
sendAdmins "\`Official-Devices CI%0A%0ASomeone has merged a failing file. Please look in ASAP.\`%0A%0A\`Error message: ${ERROR_MESSAGE}\`%0A%0A\`File: ${FAILED_FILE}\`%0A%0A${ADMINS}"
else
sendAdmins "\`Official-Devices CI\`%0A%0A**I am building master branch job.** %0A**Commit Point:** [${COMMIT_SMALL_HASH}](https://github.com/PixelExperience/official_devices/commit/${COMMIT_HASH})"
pushToGit
fi
}
function pushToGit(){
if[-z"$GIT_PR_NUMBER"]&&[-n"$(${GIT_CMD} status -s)"];then