-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
23 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,59 @@ | ||
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 | ||
- name: Convert Markdown to HTML | ||
run: | | ||
mkdir -p _site | ||
mkdir -p _site # Create the _site directory if it doesn't exist | ||
# Find all Markdown files and convert them to HTML | ||
find . -name "*.md" -type f | while read file; do | ||
pandoc "$file" --standalone --toc -o "_site/$(basename "${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 }} |