Skip to content

Commit

Permalink
fix: website generation and deployment
Browse files Browse the repository at this point in the history
add distribution and source downloads to the website
migrate to Github Actions
  • Loading branch information
kevinchappell committed Feb 2, 2020
1 parent 1314b85 commit 6ba8ce0
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 86 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Demo

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12]
steps:
- uses: actions/checkout@v2
- name: Set up Nodejs ${{ matrix.node }}
uses: actions/setup-node@v1
- name: Install dependencies
env:
CI: true
run: npm install
- name: Build the plugin
run: npm run build
- name: Deploy the plugin
if: success()
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
FORMBUILDER_WEBSITE_DIR: ${{ secrets.FORMBUILDER_WEBSITE_DIR }}
FORMBUILDER_WEBSITE_REPO: ${{ secrets.FORMBUILDER_WEBSITE_REPO }}
run: |
echo "https://${{ secrets.GH_TOKEN }}:@github.com" > .git/credentials
git config --global credential.helper "store --file=.git/credentials"
git config --local user.email "[email protected]"
git config --local user.name "Kevin Chappell"
git clone --depth 1 ${{ secrets.FORMBUILDER_WEBSITE_REPO }} ${{ secrets.FORMBUILDER_WEBSITE_DIR }} 2> /dev/null
npm run deploy:all
32 changes: 32 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [12]
steps:
- uses: actions/checkout@v2
- name: Set up Nodejs ${{ matrix.node }}
uses: actions/setup-node@v1
- name: Install dependencies
env:
CI: true
run: npm install
- name: Build the plugin
run: npm run build
- name: Publish the plugin
if: success()
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
FORMBUILDER_WEBSITE_DIR: ${{ secrets.FORMBUILDER_WEBSITE_DIR }}
FORMBUILDER_WEBSITE_REPO: ${{ secrets.FORMBUILDER_WEBSITE_REPO }}
run: npx semantic-release
54 changes: 0 additions & 54 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
site_name: formBuilder
site_url: https://formbuilder.online
site_dir: site/src/docs
site_dir: site/public/docs
repo_url: https://github.com/kevinchappell/formBuilder
repo_name: 'GitHub'
site_description: A jQuery plugin for drag and drop form creation
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"build:all": "npm-run-all build:plugins build:vendor build copy",
"copy": "cp -a dist/* demo/assets/js/ && cp CONTRIBUTING.md docs/contributing.md && cp LICENSE docs/license.md && mkdir -p demo/assets/lang && cp node_modules/formbuilder-languages/*.lang demo/assets/lang/",
"deploy:all": "npm-run-all deploy:demo deploy:site",
"deploy:demo": "node tools/deploy.js",
"deploy:site": "npm run-script docs && cd site/ && npm run-script deploy && cd ../",
"deploy:demo": "node tools/deploy-demo.js",
"deploy:site": "node tools/deploy-site.js",
"docs": "mkdocs build",
"font": "babel-node tools/icon-font",
"lint": "eslint ./src --ext .js || true",
Expand Down
2 changes: 1 addition & 1 deletion tools/build-vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ const vendor = Object.keys(pkg.dependencies).map(require.resolve)
* Concatenates the vendor files into a single vendor file for the demo
* @return {Function} concat
*/
concat(vendor, `${targetDir}/vendor.js`, function(err, data) {
concat(vendor, `${targetDir}/vendor.js`, err => {
if (err) throw err
})
15 changes: 15 additions & 0 deletions tools/deploy-demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const { exec } = require('child_process')
const pkg = require('../package.json')

const commands = [
'git add --all',
`git commit -am "${pkg.version}"`,
'git push origin $(git subtree split --prefix demo $(git rev-parse --abbrev-ref HEAD)):gh-pages --force',
]

// try to deploy the demo
try {
exec(commands.join(' && '), err => !err && console.log('Demo successfully deployed'))
} catch (e) {
console.error(e)
}
16 changes: 16 additions & 0 deletions tools/deploy-site.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { exec } = require('child_process')
const pkg = require('../package.json')

const commands = [
`npm version ${pkg.version}`,
'git push origin master',
]

const cwd = process.env.FORMBUILDER_WEBSITE_DIR || 'site'

// try to deploy the demo
try {
exec(commands.join(' && '), { cwd }, err => !err && console.log('Site successfully deployed'))
} catch (e) {
console.error(e)
}
28 changes: 0 additions & 28 deletions tools/deploy.js

This file was deleted.

0 comments on commit 6ba8ce0

Please sign in to comment.