Skip to content

Commit c4e7027

Browse files
chore: create draft item for post PRs (#50)
Signed-off-by: Tsung-Ju Lii <[email protected]>
1 parent 6b9725d commit c4e7027

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/workflows/create_new_post_pr.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ jobs:
2525
branch_name=$(echo "${{ github.event.inputs.name }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
2626
echo "Branch name: ${branch_name}"
2727
git checkout -b "$branch_name"
28-
git commit --allow-empty -m "create PR from branch ${branch_name}"
28+
29+
# Create the draft item
30+
touch drafts/${branch_name}
31+
git add drafts
32+
git commit -m "create PR from branch ${branch_name}"
33+
2934
git push origin "$branch_name"
3035
echo "branch_name=$branch_name" >> $GITHUB_OUTPUT
3136

.github/workflows/generate_post_from_pr.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ jobs:
1818
id: create_post
1919
run: |
2020
PR_TITLE=${{ github.event.pull_request.title }}
21-
PR_TITLE=${PR_TITLE#post/}
21+
DRAFT_TITLE=${PR_TITLE#post/}
22+
23+
# Remove the draft item
24+
git rm drafts/${DRAFT_TITLE}
25+
2226
DATE=$(date +'%Y-%m-%d')
23-
PR_TITLE="${DATE}-${PR_TITLE}"
27+
POST_TITLE="${DATE}-${DRAFT_TITLE}"
2428
PR_BODY=${{ github.event.pull_request.body }}
25-
POST_FILE="posts/${PR_TITLE}.md"
29+
POST_FILE="posts/${POST_TITLE}.md"
2630
echo "${PR_BODY}" >> $POST_FILE
2731
2832
- name: Commit and push changes

0 commit comments

Comments
 (0)