Add labels to update_crates.yml action

This commit is contained in:
lepapareil 2022-07-15 15:45:30 +02:00 committed by GitHub
parent 0bdd778553
commit a505fc672c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,7 +38,7 @@ jobs:
ACTUAL_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_BRANCHE_NAME}" --state "open" --json number --jq .[].number)
ACTUAL_PR_NUMBER=${ACTUAL_PR_NUMBER:-0}
echo "ACTUAL_PR_NUMBER=${ACTUAL_PR_NUMBER}" | tee -a "${GITHUB_ENV}"
- name: Close actual pull request
run: |
if [ ${ACTUAL_PR_NUMBER} -eq 0 ] ; then
@ -59,8 +59,8 @@ jobs:
echo " - ${comment}"
exit 1
fi
fi
fi
- name: Push updates to branch
run: |
git config --local user.email "action@github.com"
@ -69,14 +69,14 @@ jobs:
git commit -am "ˉᵇᵒᵗˉUpdate crates on $(date "+%y/%m/%d %H:%M")"
git push --set-upstream origin "${BOT_UPDATE_BRANCHE_NAME}" && git_exit_code=0 || git_exit_code=$?
if [ ${git_exit_code} -eq 0 ] ; then
echo " - ✅ push crates update to ${BOT_UPDATE_BRANCHE_NAME} succeeds."
echo " - ✅ push crates update to ${BOT_UPDATE_BRANCHE_NAME} succeeds."
else
echo " - ❌ A problem occurs when attempting to push crates update to origin/${BOT_UPDATE_BRANCHE_NAME}."
exit 1
fi
branch_exists=$(git ls-remote | (grep -c "${BOT_UPDATE_BRANCHE_NAME}" || true))
if [ ${branch_exists} -eq 1 ] ; then
echo " - ✅ The origin/${BOT_UPDATE_BRANCHE_NAME} now branch exists on remote."
echo " - ✅ The origin/${BOT_UPDATE_BRANCHE_NAME} now branch exists on remote."
else
echo " - ❌ Git push command succeeds but origin/${BOT_UPDATE_BRANCHE_NAME} still does not exist on remote."
exit 1
@ -100,13 +100,20 @@ jobs:
sed "s/Updating //g" | \
sed "s/: updated to / -> /g" | \
sed "s/^=>/###/g" | \
sed "s/^ /- /g" > "${pr_comment_file}"
sed "s/^ /- /g" > "${pr_comment_file}"
pr_comment="$(cat "${pr_comment_file}")"
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
gh pr comment "${NEW_PR_NUMBER}" --body "${pr_comment}" && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
echo " - ✅ Comment updates list to pull request succeeds."
echo " - ✅ Comment updates list to pull request n° ${NEW_PR_NUMBER} succeeds."
else
echo " - ❌ A problem occurs when attempting to create updates list comment in new pull request n°${NEW_PR_NUMBER}."
echo " - ❌ A problem occurs when attempting to create updates list comment into new pull request n°${NEW_PR_NUMBER}."
exit 1
fi
gh pr edit "${NEW_PR_NUMBER}" --add-label "bot,dependencies" && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
echo " - ✅ Adding Label to pull request n° ${NEW_PR_NUMBER} succeeds."
else
echo " - ❌ A problem occurs when attempting to add labels into new pull request n°${NEW_PR_NUMBER}."
exit 1
fi