From 01dd23a17eca8ad95035fa5efe78ec495a4c262c Mon Sep 17 00:00:00 2001 From: Yuta Kasai Date: Tue, 26 Nov 2024 13:07:09 +0900 Subject: [PATCH] Set title and description written in line-openapi PR (#721) https://github.com/line/line-openapi/pull/74 --- .github/workflows/generated-code.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generated-code.yml b/.github/workflows/generated-code.yml index 92d185a9..4640d8a1 100644 --- a/.github/workflows/generated-code.yml +++ b/.github/workflows/generated-code.yml @@ -18,6 +18,7 @@ jobs: submodules: recursive - name: Update submodules run: git submodule update --remote --recursive + - uses: actions/setup-node@v4 - name: Set up Python uses: actions/setup-python@v5 with: @@ -36,12 +37,30 @@ 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 . git commit -m "Code are generated by openapi generator" - 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 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 }}