Code Monkey home page Code Monkey logo

ember-cli-deploy-git's Introduction

ember-cli-deploy-git

This is an ember-cli-deploy plugin for deploying your built application to a git branch. It's particularly handy for deploying to GitHub Pages.

If you have a recent version of git that supports git worktree, and you're deploying to the same repo you're working in, we automatically use git worktree to avoid any extra cloning.

Installation

ember install ember-cli-deploy ember-cli-deploy-build ember-cli-deploy-git

Configuration

In config/deploy.js, (which ember-cli-deploy will helpfully generate for you), you can pass the following options:

  • branch: The branch that we will deploy to. It must already exist. Defaults to "gh-pages"
  • repo: The repo that we will deploy to. It defaults to the value of your containing repo's origin remote.
  • worktreePath: Path where we will create/update a working tree to manipulate the deployment branch. Defaults to ../deploy-${project.name()}, relative to your project.
  • destDir: A directory within the given branch that we will deploy to. Defaults to the root of the repo.
  • commitMessage: Message to use when committing the deployment, where %@ is replaced with the current git revision.

A complete example:

ENV.git = {
  repo: '[email protected]:ef4/ember-cli-deploy-git.git',
  branch: 'deploys',
  worktreePath: '/tmp/ef4-deploy',
  commitMessage: 'Deployed %@'
};

Usage

Github Pages First-Time Setup

  1. Make sure the branch named gh-pages exists. If it doesn't, you can do git checkout --orphan gh-pages; git commit --allow-empty; git push -u origin gh-pages.

  2. Configure your application to run correctly in the Github environment by setting these things in your config/environment.js:

if (environment === 'production') {
  ENV.rootURL = '/your-repo-name';
  ENV.locationType = 'hash';
}
  1. Add demoURL to your package.json's ember-addon section to be picked up by https://www.emberaddons.com and https://emberobserver.com:
"ember-addon": {
  "configPath": "tests/dummy/config",
  "demoURL": "http://your-user-name.github.io/your-repo-name"
}

If you're using Ember-CLI 2.6 or older, you will need to use baseURL instead of rootURL.

Coordination With Other Plugins

This plugin checks out the target branch during the prepare phase of the deploy, and writes the new build output there during the upload phase. Between those two phases, the location of this checkout is available at context.gitDeploy.worktreePath for other plugins that wish to pull information from the previous deployed commit.

How to Deploy

ember deploy production

ember-cli-deploy-git's People

Contributors

bravo-kernel avatar dcyriller avatar dfreeman avatar ef4 avatar ember-tomster avatar jeffjewiss avatar kpfefferle avatar lolmaus avatar machty avatar pangratz avatar thomasbrus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ember-cli-deploy-git's Issues

README format

Thanks for contributing this plugin to the ecosystem! To make composing plugins as easy as possible, we're encouraging plugin authors to conform to a README format that includes some key sections that are missing from your README. You can see a thorough example of READMEs in the preferred format at https://github.com/ember-cli-deploy/ember-cli-deploy-redis and https://github.com/ember-cli-deploy/ember-cli-deploy-json-config.

In particular, it would be great to see your README gain the "ember-cli-deploy Hooks Implemented", "Prerequisites", and "Plugins known to work well with this one" sections.

Error on deploy: gh-pages exits with nonzero status

Getting this error pretty frequently. Restarting my computer fixes it.

Error: git push [email protected]:jeffdaley/camp-pain.git gh-pages exited with nonzero status
Error: git push [email protected]:jeffdaley/camp-pain.git gh-pages exited with nonzero status
    at ChildProcess.<anonymous> (/Users/jeffdaley/Code/camp-pain/node_modules/ember-cli-deploy-git/lib/run.js:17:19)
    at ChildProcess.emit (events.js:315:20)
    at ChildProcess.EventEmitter.emit (domain.js:482:12)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)Pipeline aborted

Thanks for looking into it!

Issue when deploying multiple times for same repo

Reproduction App: https://github.com/alexdiliberto/deploy-dummy-app/commits/gh-pages

  1. Create a new app with some dummy code
  2. Setup new gh-pages branch
  3. Do first deploy using ember deploy production. Looks good.
  4. Now make some small change to the code
  5. Deploy again using ember deploy production
  6. Issue: Notice that my change didn't actually get deployed to https://alexdiliberto.com/deploy-dummy-app/. Also note theres a error when trying to switch to the gh-pages branch
$ git checkout gh-pages
fatal: 'gh-pages' is already checked out at '/private/tmp/deploy'

EDIT: Ok looks like the changes do propagate but it just takes time...I checked again about 15 minutes later (didn't check but probably just a small caching issue). But the gh-pages branch error still persists and you can't switch to that branch

Add CNAME and 404.html

Thanks a lot for this plugin, it worked out-of-the-box for me, which is amazing given I’m still very new to Ember 👏

I wonder if we could add options so that the deploy would add a CNAME file with a custom domain, and optionally a 404.html which would be the same as index.html so that we don’t need the ENV.locationType = 'hash'; setting. It’s somewhat of a hack because the server responds with 404 status, but user’s don’t care, the app will still show

Happy to help with this if you point me to the right places. Or maybe there is a workaround for what I need? I’d greatly appreciate your help. Thanks!

Deployment error running git reset --hard

Running into the following when trying to deploy using ember deploy production:

Deploying [===>----] 50% [plugin: git -> prepare]Error: git reset --hard exited with nonzero status

 at ChildProcess.<anonymous> (/home/vagrant/projects/cell-deploy/node_modules/ember-cli-deploy-git/lib/run.js:19:19)

Error: git reset --hard exited with nonzero status
  at emitTwo (events.js:126:13)
  at ChildProcess.emit (events.js:214:7)
  at maybeClose (internal/child_process.js:925:16)
  at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
Pipeline aborted

"Could not find app javascript" when following docs on an embroider app

I have a brand new app using embroider for builds, and I'm trying to deploy with ember-cli-deploy-git. Following the instructions in the README, I ran into this error:

Error: Could not find app javascript: "/assets/docs.js" in index.html. Found the following instead:
 - /event-perk-grid/assets/vendor.js
 - /event-perk-grid/assets/docs.js

For more information about this error: https://github.com/thoov/stitch/wiki/Could-not-find-asset-in-entry-file-error-help

After a lot of hand-wringing, I figured out that I need a trailing slash in my rootURL.

Maybe the docs should suggest ENV.rootURL = '/your-repo-name/'; instead of ENV.rootURL = '/your-repo-name';? I'd be happy to PR it if so.

Error on deploy: 'gh-pages' is already checked out

I followed the setup instructions to the letter. When I try to deploy I receive this error...

λ ember deploy production
DEPRECATION: ember-cli-babel 5.x has been deprecated. Please upgrade to at least ember-cli-babel 6.6. Version 5.2.8 located: covid-azores -> ember-cli-deploy-github-pages -> ember-cli-babel
Deploying [>------] 14% [plugin: github-pages -> willDeploy]DEPRECATION: ember-cli-babel 5.x has been deprecated. Please upgrade to at least ember-cli-babel 6.6. Version 5.2.8 located: C:\Users\Pete\dev\covid-azores\node_modules\ember-cli-deploy-github-pages\node_modules\ember-cli-babel
WARNING: You have not included `ember-cli-shims` in your project's `bower.json` or `package.json`. This only works if you provide an alternative yourself and unset `app.vendorFiles['app-shims.js']`.
WARNING: Option "nodeWorker" is deprecated since [email protected]. Please use "workerType" instead.
cleaning up...
Deploying [==>----] 43% [plugin: git -> prepare]fatal: 'gh-pages' is already checked out at 'C:/Users/Pete/dev/deploy-covid-azores'
Error: Command failed: git checkout  gh-pages
fatal: 'gh-pages' is already checked out at 'C:/Users/Pete/dev/deploy-covid-azores'

Error: Command failed: git checkout  gh-pages
fatal: 'gh-pages' is already checked out at 'C:/Users/Pete/dev/deploy-covid-azores'

    at checkExecSyncError (child_process.js:630:11)
    at execSync (child_process.js:666:15)
    at Command.execSync (C:\Users\Pete\dev\covid-azores\node_modules\gitty\lib\command.js:52:10)
    at Repository.checkoutSync (C:\Users\Pete\dev\covid-azores\node_modules\gitty\lib\repository.js:432:7)
    at Class.prepare (C:\Users\Pete\dev\covid-azores\node_modules\ember-cli-deploy-github-pages\index.js:72:14)
    at Object.fn (C:\Users\Pete\dev\covid-azores\node_modules\ember-cli-deploy\lib\tasks\pipeline.js:93:21)
    at Pipeline._notifyPipelinePluginHookExecution (C:\Users\Pete\dev\covid-azores\node_modules\ember-cli-deploy\lib\models\pipeline.js:173:19)
    at tryCatch (C:\Users\Pete\dev\covid-azores\node_modules\rsvp\dist\rsvp.js:525:12)
    at invokeCallback (C:\Users\Pete\dev\covid-azores\node_modules\rsvp\dist\rsvp.js:538:13)
    at publish (C:\Users\Pete\dev\covid-azores\node_modules\rsvp\dist\rsvp.js:508:7)
    at flush (C:\Users\Pete\dev\covid-azores\node_modules\rsvp\dist\rsvp.js:2415:5)
    at processTicksAndRejections (internal/process/task_queues.js:79:11)Pipeline aborted

Tweaking files before commit/push

With #14 landed to allow simple deploys into different directories in the target branch, I wanted to pick your brain on a question that arises as we start thinking ahead to more complex version management in ember-cli-addon-docs.

Suppose after deploying a build into a particular subdirectory, we want to update some kind of manifest of available versions in the root of the branch. Today, because staging, committing, and pushing the files all occurs in a single step, there's no opportunity for other deploy plugins to make such tweaks. I could see three approaches for enabling this:

  • move the staging of files into an earlier hook, allowing other plugins to step in and make changes before everything is committed and pushed (down side: it's a little awkward to be reading this plugin's config to figure out where the staged files are)
  • accept some kind of callback as configuration that this plugin invokes at the right time, passing information like the directory where things are staged (down side: this is kind of a non-standard pattern for how deploy plugins tend to work, as far as I've seen)
  • declare deploys of this complexity out of scope of this plugin, since most common usage won't ever need to do things like this (down side: we'd probably end up just duplicating most of the code here into ember-cli-addon-docs)

Do you have any thoughts on which of these paths might be a good way forward, or whether there's a better option I'm not considering? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.