Use personal token to create pull request for update_crates.yml action

This commit is contained in:
lepapareil 2022-07-15 15:05:01 +02:00
parent e446ce1cda
commit 1e1c2a01bd
No known key found for this signature in database
GPG Key ID: F4F06B068FB00692

View File

@ -32,6 +32,7 @@ jobs:
echo " - ❌ A problem occurs updating crates. Please refer to ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} logs." echo " - ❌ A problem occurs updating crates. Please refer to ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} logs."
exit 1 exit 1
fi fi
- name: Get actual pull request id - name: Get actual pull request id
run: | run: |
ACTUAL_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_BRANCHE_NAME}" --state "open" --json number --jq .[].number) ACTUAL_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_BRANCHE_NAME}" --state "open" --json number --jq .[].number)
@ -80,8 +81,18 @@ jobs:
echo " - ❌ Git push command succeeds but origin/${BOT_UPDATE_BRANCHE_NAME} still does not exist on remote." echo " - ❌ Git push command succeeds but origin/${BOT_UPDATE_BRANCHE_NAME} still does not exist on remote."
exit 1 exit 1
fi fi
- name: Create new pull request - name: Create new pull request
run: | run: |
GITHUB_TOKEN=${{ secrets.LEPAPAREIL_CI_TOKEN }}
gh pr create --fill --base master --head "${BOT_UPDATE_BRANCHE_NAME}" && gh_exit_code=0 || gh_exit_code=$?
if [ ${gh_exit_code} -eq 0 ] ; then
NEW_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_BRANCHE_NAME}" --state "open" --json number --jq .[].number)
echo " - ✅ Creation of pull request n°${NEW_PR_NUMBER} succeeds."
else
echo " - ❌ A problem occurs when attempting to create new pull request."
exit 1
fi
pr_comment_file="comment_file.md" pr_comment_file="comment_file.md"
(grep -vE "newest|crates.io index" "${update_crates_output}" || true) | \ (grep -vE "newest|crates.io index" "${update_crates_output}" || true) | \
tr -s ' ' | \ tr -s ' ' | \
@ -90,12 +101,12 @@ jobs:
sed "s/: updated to / -> /g" | \ sed "s/: updated to / -> /g" | \
sed "s/^=>/###/g" | \ sed "s/^=>/###/g" | \
sed "s/^ /- /g" > "${pr_comment_file}" sed "s/^ /- /g" > "${pr_comment_file}"
pr_comment="$(cat "${pr_comment_file}")" pr_comment="$(cat "${pr_comment_file}")"
gh pr create --title "ˉᵇᵒᵗˉUpdate crates" --base master --head "${BOT_UPDATE_BRANCHE_NAME}" --body "${pr_comment}" && gh_exit_code=0 || gh_exit_code=$? 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 if [ ${gh_exit_code} -eq 0 ] ; then
NEW_PR_NUMBER=$(gh pr list --repo "${REPO}" --head "${BOT_UPDATE_BRANCHE_NAME}" --state "open" --json number --jq .[].number) echo " - ✅ Comment updates list to pull request succeeds."
echo " - ✅ Creation of pull request n°${NEW_PR_NUMBER} succeeds."
else else
echo " - ❌ A problem occurs when attempting to create new PR." echo " - ❌ A problem occurs when attempting to create updates list comment in new pull request n°${NEW_PR_NUMBER}."
exit 1 exit 1
fi fi