Skip to content

Commit c6dffe1

Browse files
feat: create post thru PR (#47)
* feat: create post thru PR Signed-off-by: Tsung-Ju Lii <[email protected]> * update --------- Signed-off-by: Tsung-Ju Lii <[email protected]>
1 parent 98d73fb commit c6dffe1

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title:
3+
layout: post
4+
comments: false
5+
tags:
6+
---
7+
8+
<!--
9+
The repo generates a post with this template. The file's name will be the PR's title along with its date.
10+
Whatever you write here will be the post.
11+
-->
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Create Post from PR
2+
3+
on:
4+
pull_request:
5+
types: [labeled, closed]
6+
7+
jobs:
8+
create_post:
9+
if: ${{ (github.event.pull_request.merged == true && github.event.label.name == 'post') }}
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Create post file
17+
id: create_post
18+
run: |
19+
PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
20+
DATE=$(date +'%Y-%m-%d')
21+
PR_TITLE="${DATE}-${PR_TITLE}"
22+
PR_BODY=${{ github.event.pull_request.body }}
23+
POST_FILE="posts/${PR_TITLE}.md"
24+
echo "${PR_BODY}" >> $POST_FILE
25+
26+
- name: Commit and push changes
27+
run: |
28+
git config --global user.name 'github-actions[bot]'
29+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
30+
git add posts/
31+
git commit -m "Create post: ${{ github.event.pull_request.title }}"
32+
git push origin main

.github/workflows/deploy.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ jobs:
1919

2020
- id: stack
2121
uses: freckle/stack-action@v5
22-
22+
with:
23+
stack-build-arguments: --fast # No pedantic for now
24+
2325
- run: stack exec site build
2426

2527
- run: |

0 commit comments

Comments
 (0)