Skip to content

Instantly share code, notes, and snippets.

@mattbrailsford
Last active September 12, 2021 13:49
Show Gist options
  • Save mattbrailsford/95c6f42fd133aac8a971213346ef1a28 to your computer and use it in GitHub Desktop.
Save mattbrailsford/95c6f42fd133aac8a971213346ef1a28 to your computer and use it in GitHub Desktop.
Configuration for deploying a NUXT static site to github pages
language: node_js
node_js:
- "8"
cache:
directories:
- "node_modules"
branches:
only:
- master
install:
- npm install
- npm run generate
script:
- echo "Skipping tests"
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_ACCESS_TOKEN # Set in travis-ci.org dashboard, marked secure https://docs.travis-ci.com/user/deployment/pages/#Setting-the-GitHub-token
target-branch: gh-pages
local-dir: dist
on:
branch: master
environment:
# Nuxt required node v8 minimum
nodejs_version: "8"
# Encrypt sensitive data (https://ci.appveyor.com/tools/encrypt)
github_access_token:
secure: ENCRYPTED_GITHUB_ACCESS_TOKEN
github_email:
secure: ENCRYPTED_GITHUB_EMAIL
# Only run on master branch
branches:
only:
- master
# Install scripts. (runs after repo cloning)
install:
# switch nodejs version
- ps: Install-Product node $env:nodejs_version
# install modules
- npm install
# generate static files
- npm run generate
# configure global git credentials store (https://www.appveyor.com/docs/how-to/git-push/)
- git config --global credential.helper store
- ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:github_access_token):x-oauth-basic@github.com`n"
- git config --global user.email $env:github_email
# deploy to github pages
- npm run deploy
# No tests to run
test: off
# Don't actually build.
build: off
{
"name": "nuxt",
"version": "1.0.0",
"description": "Nuxt.js project",
"author": "",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"deploy": "push-dir --dir=dist --branch=gh-pages --cleanup",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"nuxt": "^1.0.0"
},
"devDependencies": {
"babel-eslint": "^8.2.1",
"eslint": "^4.15.0",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-vue": "^4.0.0",
"push-dir": "^0.4.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment