[update]gitaction 수정중 #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Convert and Deploy DevelopLog to Jekyll | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '2.7.8' # 기존 Ruby 버전 유지 | |
- name: Install compatible FFI | |
run: gem install ffi -v 1.17.0 # 호환 가능한 버전 설치 | |
- name: Install compatible Bundler | |
run: gem install bundler -v 2.4.22 # 호환 가능한 버전 설치 | |
- name: Install dependencies | |
run: bundle install | |
- 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: Checkout GitHub Pages Repository | |
uses: actions/checkout@v2 | |
with: | |
repository: YourGitHubPagesRepoOwner/YourGitHubPagesRepoName | |
path: gh-pages | |
- name: Copy Converted Files to GitHub Pages Repo | |
run: | | |
cp _posts/* gh-pages/_posts/ | |
- name: Commit and Push Changes | |
run: | | |
cd gh-pages | |
git config --global user.email "github-actions[bot]" | |
git config --global user.name "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Bulk commit of converted posts" | |
git push https://${{ secrets.GH_PAT }}@github.com/GoldenPearls/GoldenPearls.github.io.git #자신의 깃허브명으로 바꿔야 함 |