Skip to content

Commit 7be63c7

Browse files
authored
Set title and description written in line-openapi PR (#1074)
line/line-openapi#74
1 parent e90faf6 commit 7be63c7

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

.github/workflows/update-code.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,35 @@ jobs:
4848
## Run if diff exists and event is not pull request, and make PR
4949
- if: ${{ github.event_name != 'pull_request' && env.DIFF_IS_EMPTY != 'true' }}
5050
run: |
51+
BRANCH_NAME="update-diff-${{ env.CURRENT_DATETIME }}"
52+
5153
git config user.name github-actions
5254
git config user.email [email protected]
53-
git checkout -b update-diff-${{ env.CURRENT_DATETIME }}
55+
git checkout -b $BRANCH_NAME
5456
5557
git add line-openapi
5658
git add lib/**
5759
git commit -m "Codes are generated by openapi"
5860
59-
git push origin update-diff-${{ env.CURRENT_DATETIME }}
60-
gh pr create -B ${{ github.ref_name }} -t "Codes are generated by openapi generator" -b "" --label "line-openapi-update"
61+
git push origin $BRANCH_NAME
62+
63+
# Determine Change Type via Submodule Script
64+
CHANGE_TYPE=$(npx zx ./line-openapi/tools/determine-change-type.mjs)
65+
echo "Determined change type: $CHANGE_TYPE"
66+
67+
# Determine PR title and body
68+
if [ "$CHANGE_TYPE" == "submodule-update" ]; then
69+
# Fetch PR info from submodule
70+
npx zx ./line-openapi/tools/get-pr-info.mjs
71+
PR_INFO=$(cat pr_info.json)
72+
TITLE=$(echo "$PR_INFO" | jq -r '.title')
73+
BODY=$(echo "$PR_INFO" | jq -r '.url')$'\n\n'$(echo "$PR_INFO" | jq -r '.body')
74+
else
75+
# Default PR title and body
76+
TITLE="Codes are generated by openapi generator"
77+
BODY="⚠Reviewer: Please edit this description to include relevant information about the changes.⚠"
78+
fi
79+
80+
gh pr create -B ${{ github.ref_name }} -H $BRANCH_NAME -t "$TITLE" -b "$BODY" --label "line-openapi-update"
6181
env:
6282
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)