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
94 changes: 71 additions & 23 deletions .github/workflows/build-hexo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ on:
- ci/build-hexo
workflow_dispatch:

permissions:
contents: read
actions: write

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

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

# Prepare Hexo Showcase Repo
- name: Checkout Hexo showcase repo
- 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
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 @@ -72,15 +90,9 @@ jobs:
git config --global user.name "Kaede Akatsuki"
git add .
git status

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
git commit -m "GitHub Actions update posts - ${{ github.run_number }}" || echo "No changes to commit"
git push origin master

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

# 3. Deploy Static Site (Move public -> docs)
- 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

- name: Collect Hexo dist
working-directory: notion-down-hexo-showcase
run: |
pwd && ls -l
rm -rf docs
# Move public from hexo-blog subdirectory to root docs directory
mv hexo-blog/public docs
mv ../hexo-public docs
ls -l docs
echo "Configure CNAME"
if [ -f "docs/CNAME" ]; then
Expand All @@ -120,12 +154,26 @@ 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

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
git commit -m "GitHub Actions deploy - ${{ github.run_number }}"
git push origin master

cleanup-artifacts:
needs: [publish-github-hexo]
if: always()
runs-on: ubuntu-latest
steps:
- name: Delete build artifacts (hexo-build)
uses: geekyeggo/delete-artifact@v2
with:
name: hexo-build
failOnError: false

- name: Delete build artifacts (hexo-public)
uses: geekyeggo/delete-artifact@v2
with:
name: hexo-public
failOnError: false
59 changes: 41 additions & 18 deletions .github/workflows/build-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ on:

permissions:
contents: write # Required to push to deploy/readme branch
actions: write

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

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

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

# 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
pwd && ls -l

- name: Switch to deploy branch
- 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
uses: actions/checkout@v4
with:
ref: deploy/readme
token: ${{ secrets.GITHUB_TOKEN }}
clean: true

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

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

ls -l ./build/NotionDown

Expand All @@ -76,10 +87,11 @@ 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

# Cleanup build dir
rm -rf build


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

# Check for modifications
Expand All @@ -97,3 +109,14 @@ jobs:
git status
git push origin deploy/readme
fi

cleanup-artifacts:
needs: [publish-github-readme]
if: always()
runs-on: ubuntu-latest
steps:
- name: Delete build artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: readme-build
failOnError: false
15 changes: 15 additions & 0 deletions .github/workflows/pycorrector-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- feature/spell-inspect
workflow_dispatch:

permissions:
contents: read
actions: write

jobs:
build-pycorrector-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,3 +44,14 @@ jobs:
with:
name: spell-inspect-results
path: ./build/SpellInspect

cleanup-artifacts:
needs: [build-pycorrector-test]
if: always()
runs-on: ubuntu-latest
steps:
- name: Delete build artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: spell-inspect-results
failOnError: false