From da5deb3ab6bca5f9d322d658197d96a3b0989446 Mon Sep 17 00:00:00 2001 From: Tsung-Ju Lii Date: Thu, 27 Feb 2025 19:50:40 +0800 Subject: [PATCH 1/2] feat: create post thru PR Signed-off-by: Tsung-Ju Lii --- .github/PULL_REQUEST_TEMPLATE/post.md | 6 ++++ .github/workflows/create_post_from_pr.yaml | 32 ++++++++++++++++++++++ .github/workflows/deploy.yaml | 4 ++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE/post.md create mode 100644 .github/workflows/create_post_from_pr.yaml diff --git a/.github/PULL_REQUEST_TEMPLATE/post.md b/.github/PULL_REQUEST_TEMPLATE/post.md new file mode 100644 index 0000000..383be72 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/post.md @@ -0,0 +1,6 @@ +--- +title: +layout: post +comments: false +tags: +--- \ No newline at end of file diff --git a/.github/workflows/create_post_from_pr.yaml b/.github/workflows/create_post_from_pr.yaml new file mode 100644 index 0000000..c1f105c --- /dev/null +++ b/.github/workflows/create_post_from_pr.yaml @@ -0,0 +1,32 @@ +name: Create Post from PR + +on: + pull_request: + types: [labeled, closed] + +jobs: + create_post: + if: ${{ (github.event.pull_request.merged == true && github.event.label.name == 'post') }} + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Create post file + id: create_post + run: | + PR_TITLE=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-') + DATE=$(date +'%Y-%m-%d') + PR_TITLE="${DATE}-${PR_TITLE}" + PR_BODY=${{ github.event.pull_request.body }} + POST_FILE="posts/${PR_TITLE}.md" + echo "${PR_BODY}" >> $POST_FILE + + - name: Commit and push changes + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git add posts/ + git commit -m "Create post: ${{ github.event.pull_request.title }}" + git push origin main diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 4230431..d93025d 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -19,7 +19,9 @@ jobs: - id: stack uses: freckle/stack-action@v5 - + with: + stack-build-arguments: --fast # No pedantic for now + - run: stack exec site build - run: | From 22ffdc4ef7315138e9863b135825b80040937930 Mon Sep 17 00:00:00 2001 From: Tsung-Ju Lii Date: Thu, 27 Feb 2025 19:54:16 +0800 Subject: [PATCH 2/2] update --- .github/PULL_REQUEST_TEMPLATE/post.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/post.md b/.github/PULL_REQUEST_TEMPLATE/post.md index 383be72..e78724f 100644 --- a/.github/PULL_REQUEST_TEMPLATE/post.md +++ b/.github/PULL_REQUEST_TEMPLATE/post.md @@ -3,4 +3,9 @@ title: layout: post comments: false tags: ---- \ No newline at end of file +--- + +