Skip to content

GITBOOK-53: gitaction 글 작성 중 #8

GITBOOK-53: gitaction 글 작성 중

GITBOOK-53: gitaction 글 작성 중 #8

name: Update Blog Posts
on:
push:
branches:
- main # 또는 워크플로우를 트리거하고 싶은 브랜치 이름
schedule:
- cron: '40 10 * * *' # 매일 오전 10시 40분에 실행
jobs:
update_blog:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Convert Markdown to Jekyll Format
run: |
mkdir -p _posts
for file in $(find ./developLog -name '*.md'); do
filename=$(basename -- "$file")
title="${filename%.*}"
category=$(basename $(dirname "$file"))
date=$(date +"%Y-%m-%d")
new_filename="_posts/$date-$title.md"
echo "---" > $new_filename
echo "title: \"$title\"" >> $new_filename
echo "description: \"$title description\"" >> $new_filename
echo "author: \"Your Name\"" >> $new_filename
echo "date: $date 11:33:00 +0800" >> $new_filename
echo "categories: [$category]" >> $new_filename
echo "tags: [$title]" >> $new_filename
echo "pin: false" >> $new_filename
echo "math: false" >> $new_filename
echo "mermaid: false" >> $new_filename
echo "image:" >> $new_filename
echo " path: /assets/images/$title.png" >> $new_filename
echo " alt: \"$title image\"" >> $new_filename
echo "---" >> $new_filename
cat "$file" >> $new_filename
# Add and commit each file with the title as the commit message
git add $new_filename
git commit -m "Add post: $title"
done
- name: Push changes
run: |
git add .
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git push https://${{ secrets.GH_PAT }}@github.com/GoldenPearls/velog.git # 자신의 깃허브명으로 바꿔야 함
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install feedparser gitpython