Skip to content

feat: create post thru PR #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title:
layout: post
comments: false
tags:
---

<!--
The repo generates a post with this template. The file's name will be the PR's title along with its date.
Whatever you write here will be the post.
-->
32 changes: 32 additions & 0 deletions .github/workflows/create_post_from_pr.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down