forked from nrwl/nx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: deploy netlify on merge to master (nrwl#72)
- Loading branch information
1 parent
b718180
commit c4a5f8d
Showing
6 changed files
with
2,318 additions
and
74 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
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,35 @@ | ||
import { existsSync } from 'fs'; | ||
import * as minimist from 'minimist'; | ||
import * as NetlifyClient from 'netlify'; | ||
import { join } from 'path'; | ||
|
||
const token = process.env.NETLIFY_AUTH_TOKEN; | ||
|
||
const argv = minimist(process.argv.slice(2)); | ||
|
||
const netlifyClient = new NetlifyClient(token); | ||
const root = join(__dirname, '../..'); | ||
const outDir = join(root, argv.outputPath); | ||
|
||
if (!existsSync(outDir)) { | ||
throw new Error(`${outDir} does not exist`); | ||
} | ||
|
||
(async () => { | ||
try { | ||
const sites = await netlifyClient.listSites(); | ||
const site = sites.find(s => argv.siteName === s.name); | ||
if (!site) { | ||
throw Error(`Could not find site ${argv.siteName}`); | ||
} | ||
console.log(`Deploying ${argv.siteName} to Netlify...`); | ||
const deployResult = await netlifyClient.deploy(site.id, outDir); | ||
console.log( | ||
`\n🚀 New version of ${argv.siteName} is running at ${ | ||
deployResult.deploy.ssl_url | ||
}!\n` | ||
); | ||
} catch (e) { | ||
console.error('Authentication Failure: Invalid Token'); | ||
} | ||
})(); |
Oops, something went wrong.