-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add PR deploys of the examples and the playground (#253)
* chore: try netlify.toml * chore: move yarn? * chore: WIP * chore: try npm * chore: idk what's going on * chore: go back to what _should_ work * chore: ignore new directory * ci(netlify): run netlify ourselves reason is that it otherwise gets confused with what to do when and how :) * ci: add env variables * ci: separate matrix step * ci: look at the file tree * ci: use find * ci: use shell for sed * chore: use replace-in-file
- Loading branch information
Showing
8 changed files
with
1,899 additions
and
13 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 |
---|---|---|
|
@@ -13,3 +13,4 @@ bower_components | |
*.iml | ||
.idea | ||
.vscode | ||
netlify-dist/ |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
/* eslint-disable no-console */ | ||
const execa = require('execa'); | ||
const replace = require('replace-in-file'); | ||
const NetlifyAPI = require('netlify'); | ||
|
||
const client = new NetlifyAPI(process.env.NETLIFY_API_KEY); | ||
|
||
function logStdOut(opts) { | ||
console.log(opts.stdout); | ||
} | ||
|
||
if (!process.env.NETLIFY_API_KEY || !process.env.NETLIFY_SITE_ID) { | ||
throw new Error( | ||
'Both NETLIFY_API_KEY and NETLIFY_SITE_ID are required. ' + | ||
'They can be found on ' + | ||
'https://app.netlify.com/sites/autocompletejs-playgrounds/settings/general' + | ||
' and https://app.netlify.com/account/applications' | ||
); | ||
} | ||
|
||
execa('yarn', ['build']) | ||
.then(logStdOut) | ||
.then(() => execa('rm', ['-rf', 'netlify-dist'])) | ||
.then(() => execa('mkdir', ['-p', 'netlify-dist/examples'])) | ||
.then(() => execa('cp', ['-r', 'examples', 'netlify-dist'])) | ||
.then(() => execa('mv', ['netlify-dist/examples/index.html', 'netlify-dist'])) | ||
.then(() => | ||
replace({ | ||
files: 'netlify-dist/index.html', | ||
from: /href="\.\./g, | ||
to: 'href=".' | ||
}) | ||
) | ||
.then(() => execa('mkdir', ['-p', 'netlify-dist/test'])) | ||
.then(() => | ||
execa('cp', [ | ||
'test/playground.css', | ||
'test/playground.html', | ||
'test/playground_angular.html', | ||
'test/playground_jquery.html', | ||
'netlify-dist/test' | ||
]) | ||
) | ||
.then(() => execa('cp', ['-r', 'dist', 'netlify-dist'])) | ||
.then(() => | ||
replace({ | ||
files: [ | ||
'netlify-dist/examples/basic.html', | ||
'netlify-dist/examples/basic_angular.html', | ||
'netlify-dist/examples/basic_jquery.html' | ||
], | ||
from: /https:\/\/cdn.jsdelivr.net\/autocomplete.js\/0/g, | ||
to: '../dist' | ||
}) | ||
) | ||
.then(() => | ||
client.deploy(process.env.NETLIFY_SITE_ID, 'netlify-dist', { | ||
draft: true, | ||
message: process.env.TRAVIS_COMMIT_MESSAGE || '' | ||
}) | ||
) | ||
.then(({deploy: {id, name, deploy_ssl_url: url}}) => | ||
console.log( | ||
'🕸 site is available at ' + | ||
url + | ||
'\n\n' + | ||
'Deploy details available at https://app.netlify.com/sites/' + | ||
name + | ||
'/deploys/' + | ||
id | ||
) | ||
); | ||
|
File renamed without changes.
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
Oops, something went wrong.