Skip to content

Commit

Permalink
improve Backport Pull Request Title & Description Quality (#2373)
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <kpango@vdaas.org>
Co-authored-by: Kosuke Morimoto <ksk@vdaas.org>
  • Loading branch information
2 people authored and vankichi committed Feb 19, 2024
1 parent e6c43b3 commit 4246def
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,20 @@ jobs:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Set context
id: set_context
- name: Get PR title and body
id: pr_info
run: |
LABEL_NAMES=`cat ${GITHUB_EVENT_PATH} | jq -r --arg PREFIX $TARGET_LABEL_NAME_PREFIX '[.pull_request.labels[]? | select(.name | startswith($PREFIX)) | .name] | join(" ")'`
echo "LABEL_NAMES=${LABEL_NAMES}" >> $GITHUB_OUTPUT # e.g.) actions/backport/v1.7 actions/backport/v1.8
echo "${LABEL_NAMES}"
echo "PR_TITLE=$(jq --raw-output .pull_request.title $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
echo "PR_BODY=$(jq --raw-output .pull_request.body $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
- name: Create PR
if: ${{ steps.set_context.outputs.LABEL_NAMES != '' }}
if: ${{ github.event.pull_request.labels.*.name == '${TARGET_LABEL_NAME_PREFIX}*' }}
env:
LABEL_NAMES: ${{ steps.set_context.outputs.LABEL_NAMES }}
PR_TITLE: ${{ steps.pr_info.outputs.PR_TITEL }}
PR_BODY: ${{ steps.pr_info.outputs.PR_BODY }}
GITHUB_USER: ${{ secrets.DISPATCH_USER }}
GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
run: |
PR_TITLE=`cat $GITHUB_EVENT_PATH | jq -r ".pull_request.title"`
PR_BODY=`cat $GITHUB_EVENT_PATH | jq -r ".pull_request.body"`
PR_NUM=`cat $GITHUB_EVENT_PATH | jq -r ".pull_request.number"`
echo "${PR_NUM} ${PR_TITLE}: ${PR_BODY}"
LABEL_NAMES=`echo "${{ github.event.pull_request.labels.*.name }}" | jq -r '[.[] | select(startswith("actions/backport/"))] | join(" ")'`
for LABEL_NAME in ${LABEL_NAMES}; do
BRANCH_NAME=`echo "${LABEL_NAME}" | sed -e "s:^${TARGET_LABEL_NAME_PREFIX}::"` # e.g) release/vx.x, main
BACKPORT_BRANCH_NAME="${BACKPORT_BRANCH_NAME_PREFIX}/${BRANCH_NAME}/${GITHUB_HEAD_REF}" # e.g) backport/release/vx.x/{current branch name}
Expand All @@ -79,6 +74,6 @@ jobs:
git push origin ${BACKPORT_BRANCH_NAME}
gh pr create --base ${BRANCH_NAME} \
--title "Backport PR #${PR_NUM} to ${BRANCH_NAME} for ${PR_TITLE}" \
--title "Backport to ${BRANCH_NAME} for ${PR_TITLE}" \
--body "${PR_BODY}"
done

0 comments on commit 4246def

Please sign in to comment.