From d6e36579fab6dd4216a2f138dd09e8ea3d332404 Mon Sep 17 00:00:00 2001 From: Yuta Kasai Date: Tue, 26 Nov 2024 11:55:43 +0900 Subject: [PATCH] NO-ISSUE Set title and description writtein in line-openapi PR --- .github/workflows/update-code.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-code.yml b/.github/workflows/update-code.yml index aeb1f7eb..6209055a 100644 --- a/.github/workflows/update-code.yml +++ b/.github/workflows/update-code.yml @@ -48,15 +48,35 @@ jobs: ## Run if diff exists and event is not pull request, and make PR - if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }} run: | + BRANCH_NAME="update-diff-${{ env.CURRENT_DATETIME }}" + git config user.name github-actions git config user.email github-actions@github.com - git checkout -b update-diff-${{ env.CURRENT_DATETIME }} + git checkout -b $BRANCH_NAME git add line-openapi git add lib/** git commit -m "Codes are generated by openapi" - git push origin update-diff-${{ env.CURRENT_DATETIME }} - gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi generator" -b "" --label "line-openapi-update" + git push origin $BRANCH_NAME + + # Determine Change Type via Submodule Script + CHANGE_TYPE=$(npx zx ./line-openapi/tools/determine-change-type.mjs) + echo "Determined change type: $CHANGE_TYPE" + + # Determine PR title and body + if [ "$CHANGE_TYPE" == "submodule-update" ]; then + # Fetch PR info from submodule + npx zx ./line-openapi/tools/get-pr-info.mjs + PR_INFO=$(cat pr_info.json) + TITLE=$(echo "$PR_INFO" | jq -r '.title') + BODY=$(echo "$PR_INFO" | jq -r '.url')$'\n\n'$(echo "$PR_INFO" | jq -r '.body') + else + # Default PR title and body + TITLE="Codes are generated by openapi generator" + BODY="⚠Reviewer: Please edit this description to include relevant information about the changes.⚠" + fi + + gh pr create -B ${{ github.ref_name }} -H $BRANCH_NAME -t "$TITLE" -b "$BODY" --label "line-openapi-update" env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}