Skip to content

Commit

Permalink
Merge d51d408 into 2d03cb8
Browse files Browse the repository at this point in the history
  • Loading branch information
brown9804 authored Jan 13, 2025
2 parents 2d03cb8 + d51d408 commit 2d09abd
Show file tree
Hide file tree
Showing 4 changed files with 1,393 additions and 178 deletions.
35 changes: 27 additions & 8 deletions .github/workflows/md-html-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
name: Convert Markdown to HTML and Deploy
name: Workflow to convert Markdown files to HTML and deploy to GitHub Pages

on:
push:
branches:
- main # Trigger the workflow on push to the main branch
- dev
- feature/*
- dev # Trigger the workflow on push to the dev branch
- feature/* # Trigger the workflow on push to any feature branch

jobs:
build-and-deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-latest # Use the latest Ubuntu environment

steps:
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v2

# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
node-version: '14' # Specify the Node.js version

# Step 3: Install npm dependencies
- name: Install dependencies
run: npm install

# Step 4: Install pandoc for Markdown to HTML conversion
- name: Install pandoc
run: sudo apt-get install -y pandoc

# Step 5: Convert all Markdown files to HTML while preserving directory structure
- name: Convert Markdown to HTML
run: |
mkdir -p _site
for file in *.md; do
mkdir -p _site # Create the _site directory if it doesn't exist
# Find all Markdown files and convert them to HTML, preserving directory structure
find . -name "*.md" -type f | while read file; do
# Create the corresponding directory in _site
mkdir -p "_site/$(dirname "$file")"
# Convert the Markdown file to HTML and save it in the corresponding directory
pandoc "$file" --standalone --toc -o "_site/${file%.md}.html"
done
# Step 6: Deploy the generated HTML files to GitHub Pages
- name: Deploy to GitHub Pages
run: |
# Configure Git with a bot email and name
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Stash any unstaged changes
git stash
# Pull the latest changes from the remote branch with rebase
git pull origin ${{ github.ref }} --rebase
git add -A # Add all changes, including untracked files
# Apply the stashed changes
git stash pop
# Add all changes, including untracked files
git add -A
# Commit the changes
git commit -m 'Deploy static HTML files'
# Push the changes to the remote branch
git push origin HEAD:${{ github.ref }}
Loading

0 comments on commit 2d09abd

Please sign in to comment.