Skip to content

Commit

Permalink
Automate docs deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Parajuli Kiran <[email protected]>
  • Loading branch information
kiranparajuli589 committed Nov 11, 2023
1 parent 0504e72 commit b00c35d
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
push:
branches:
- 'main'
paths:
- 'lib/**'
- 'demo/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
all_but_latest: true
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: '20.x.x'
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 'latest'
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- name: Build
run: bash -x build_docs.sh


38 changes: 38 additions & 0 deletions build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env sh

# This file is used to build and deploy the docs to the dist branch

DIST_BRANCH="dist"
BASE_DIR="/home/runner/work/htmlmark"

git stash && git stash clear

echo "Building Started...."
cd demo || exit
pnpm build
cd .. || exit
echo "Building Completed."


echo "Deploying Started...."
mkdir -p "${BASE_DIR}""/temp"
mv docs "${BASE_DIR}""/temp"
rm -rf docs

git fetch origin ${DIST_BRANCH}
git checkout ${DIST_BRANCH}

cp -r "${BASE_DIR}"/temp/docs/* .

curr_date=$(date)

if [ -n "$(git status --porcelain)" ]; then
git add .
git -c user.name="Kiran Parajuli" \
-c user.email="[email protected]" \
commit -m "Update the build code @ ""${curr_date}"
git push origin ${DIST_BRANCH}
fi

rm -rf "${BASE_DIR}""/temp"
echo "Deploying Docs Has Completed!"
2 changes: 1 addition & 1 deletion lib/parser/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Parsers } from "../tokenizer/index.js"
import TOKENS from "../util/index.js"
import { TOKENS } from "../util/index.js"


class Parser {
Expand Down
12 changes: 7 additions & 5 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { defineConfig } from "rollup"
import fs from "fs"
import { defineConfig } from "rollup"


const packageJsonContent = fs.readFileSync("./package.json").toString()

const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(fs.readFileSync("./package.json")).version
const version = process.env.SEMANTIC_RELEASE_NEXT_VERSION || JSON.parse(packageJsonContent).version

console.info("building version:", version)
console.info("Building version:", version)

const banner = `/**
* MDParser v${version} - a markdown parser
* HtmlMark v${version} - a markdown parser
* Copyright (c) 2020-${new Date().getFullYear()}, Kiran Parajuli. (GNU Licensed)
* https://github.com/kiranparajuli589/htmlmark
*/
/**
* DO NOT EDIT THIS FILE
* The code in this file is generated from files in ./lib/
* The code in this file is generated from files in ./lib/index.js
*/
`

Expand Down
5 changes: 0 additions & 5 deletions scripts/build_demo.sh

This file was deleted.

0 comments on commit b00c35d

Please sign in to comment.