Skip to content
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
73 changes: 23 additions & 50 deletions .github/workflows/build-hexo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

jobs:
build-hexo:
build-and-deploy-hexo:
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -44,30 +44,16 @@ jobs:
echo "---"
pwd && ls -l

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: hexo-build
path: ./build

build-hexo-generate:
needs: build-hexo
runs-on: ubuntu-latest

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: hexo-build
path: ./build

- name: Checkout Hexo source repo
# Prepare Hexo Showcase Repo
- name: Checkout Hexo showcase repo
uses: actions/checkout@v4
with:
repository: kaedea/notion-down-hexo-showcase
token: ${{ secrets.GH_TOKEN }}
path: notion-down-hexo-showcase
fetch-depth: 0 # Full history for commits

# 1. Update Source and Push
- name: Copy Notion pages to Hexo source
run: |
cp -rv ./build/Hexo/. notion-down-hexo-showcase/hexo-blog/source
Expand All @@ -86,9 +72,15 @@ jobs:
git config --global user.name "Kaede Akatsuki"
git add .
git status
git commit -m "GitHub Actions update posts - ${{ github.run_number }}" || echo "No changes to commit"
git push origin master

if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "GitHub Actions update posts - ${{ github.run_number }}"
git push origin master
fi

# 2. Build Static Site
- name: Set up Node.js
uses: actions/setup-node@v4
with:
Expand All @@ -109,36 +101,14 @@ jobs:
hexo generate
cat public/index.html

- name: Upload Hexo public artifacts
uses: actions/upload-artifact@v4
with:
name: hexo-public
path: notion-down-hexo-showcase/hexo-blog/public

publish-github-hexo:
needs: build-hexo-generate
runs-on: ubuntu-latest

steps:
- name: Checkout Hexo showcase repo
uses: actions/checkout@v4
with:
repository: kaedea/notion-down-hexo-showcase
token: ${{ secrets.GH_TOKEN }}
path: notion-down-hexo-showcase

- name: Download Hexo public artifacts
uses: actions/download-artifact@v4
with:
name: hexo-public
path: hexo-public

# 3. Deploy Static Site (Move public -> docs)
- name: Collect Hexo dist
working-directory: notion-down-hexo-showcase
run: |
pwd && ls -l
rm -rf docs
mv ../hexo-public docs
# Move public from hexo-blog subdirectory to root docs directory
mv hexo-blog/public docs
ls -l docs
echo "Configure CNAME"
if [ -f "docs/CNAME" ]; then
Expand All @@ -150,9 +120,12 @@ jobs:
working-directory: notion-down-hexo-showcase
run: |
pwd && ls -l
git config --global user.email "kidhaibara@gmail.com"
git config --global user.name "Kaede Akatsuki"
git add .
git status
git commit -m "GitHub Actions deploy - ${{ github.run_number }}"
git push origin master

if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "GitHub Actions deploy - ${{ github.run_number }}"
git push origin master
fi
47 changes: 18 additions & 29 deletions .github/workflows/build-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:
contents: write # Required to push to deploy/readme branch

jobs:
build-readme:
build-and-deploy-readme:
runs-on: ubuntu-latest

steps:
Expand All @@ -36,41 +36,31 @@ jobs:
run: |
python -m unittest tests.assemble.notion_ci_test.NotionCiTest.test_generate_read_me

- name: Dump outputs
- name: Dump outputs and stash build
run: |
echo "Generated MD file:"
cat "$(find ~/work/notion-down/notion-down/build -name "*.md" -type f | head -1)"
echo ""
echo "---"
pwd && ls -l

# Stash build artifacts to a temp location outside of the checkout
mkdir -p ../temp_build
cp -r ./build ../temp_build/
echo "Stashed artifacts to ../temp_build/build"
ls -l ../temp_build/build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: readme-build
path: ./build

publish-github-readme:
needs: build-readme
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Switch to deploy branch
uses: actions/checkout@v4
with:
ref: deploy/readme
token: ${{ secrets.GITHUB_TOKEN }}
clean: true

- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: readme-build
path: ./build

- name: Copy generated files
- name: Restore artifacts and deploy
run: |
pwd && ls -l
echo "---"
echo "Restoring artifacts..."
mkdir -p build
cp -r ../temp_build/build/* ./build/

ls -l ./build/NotionDown

Expand All @@ -86,11 +76,10 @@ jobs:
echo "mv $(find ./build -name "*.md" -type f | head -1) ./README.md"
mv $(find ./build -name "*.md" -type f | head -1) ./README.md
cat ./README.md

- name: Commit and push changes
run: |
pwd
echo ""

# Cleanup build dir
rm -rf build

echo "---"

# Check for modifications
Expand Down