Skip to content

battleaxedotco/brutalism-docs

Repository files navigation

brutalism-docs

Automated deployment to GitHub pages:

1) In package.json, add the following:

"scripts": {
    "gh-pages-deploy": "node scripts/gh-pages-deploy.js"
  }

  // ...

  "devDependencies": {
    "execa": "^4.0.0",
  }

2) Create ./.github/workflows/gh-pages-deploy.yml with the following:

  name: Deploy to github pages
  on:
    push:
      branches:
        - master
  jobs:
    gh-pages-deploy:
      name: Deploying to gh-pages
      runs-on: ubuntu-latest
      steps:
        - name: Setup Node.js for use with actions
          uses: actions/setup-node@v1.1.0
          with:
            version:  12.x
        - name: Checkout branch
          uses: actions/checkout@v2

        - name: Clean install dependencies
          run: npm ci

        - name: Run deploy script
          run: |
            git config user.name "Inventsable" && git config user.email "tom@inventsable.cc"
            npm run gh-pages-deploy

Notice in the last two lines, I'm using my GitHub account and associated email. Replace with your own

3) Create ./scripts/gh-pages-deploy.js with the following:

const execa = require("execa");
const fs = require("fs");

(async () => {
  try {
    await execa("git", ["checkout", "--orphan", "gh-pages"]);
    console.log("Automating deployment...");
    await execa("npm", ["run", "build"]);
    const folderName = fs.existsSync("dist") ? "dist" : "build";
    await execa("git", ["--work-tree", folderName, "add", "--all"]);
    await execa("git", ["--work-tree", folderName, "commit", "-m", "Automated deploy to GitHub Pages"]);
    console.log("Pushing to gh-pages branch...");
    await execa("git", ["push", "origin", "HEAD:gh-pages", "--force"]);
    await execa("rm", ["-r", folderName]);
    await execa("git", ["checkout", "-f", "master"]);
    await execa("git", ["branch", "-D", "gh-pages"]);
    console.log("Successfully deployed");
  } catch (e) {
    console.log(e.message);
    process.exit(1);
  }
})();

4) Create a ./vue.config.js file with the following:

module.exports = {
  // Notice content is the name of the repo in question:
  publicPath: '/brutalism-docs/'
}

5) Run npm install and commit this to save the package.json contents

6) Push this to any repo. GitHub will detect the action and automatically perform it.

About

API documentation for the brutalism library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published