Sage & Git (Pantheon.io)

Hi!

I’m in the process of adapting to Sage workflow, which is very similar to my current one. I usually develop locally using MAMP and Git commit changes to Pantheon.io development environment. And import database if necessary.

I’m having some issues with Sage + Pantheon. Is there anything I’m missing? When I commit my changes to the dev environment some things appear to update and some other ones don’t (Styles — I guess assets folder?).

Can anybody point me in the right direction? I would hate to have to change the way I work with Pantheon.io as a lot of my work is through it. I’m open to suggestions or similar!

Thanks!

While many people commit compiled files to their repository, it’s not generally suggested to do this. Especially if you have a proper deploy process that can accommodate this. I’m not familiar with Pantheon so I can’t give any ideas.

You’ll notice that no compiled files are in the assets directory. Everything that gets compiled goes into the dist folder, which is git ignored: https://github.com/roots/sage/blob/master/.gitignore#L3

I can tell you that Pantheon (as far as I know) doesn’t have post-deploy hooks for building the /dist/ folder or anything like that. It is considered bad practice to check compiled code into git, especially if you’re working with multiple people. That said, this is a starter theme, so it’s up to you to do whatever you need for your workflow.

I’ve been trying to get http://deploybot.com/ working with Sage deploy, but I’m working out some NPM things with them now in order to get it to build.

All that said, some of the other Roots tools make this 1000% easier.

Thank you both @kalenjohnson and @JulienMelissas!

I really enjoy working with Sage, but as I said I’m having difficulty finding a nice workflow with Pantheon. I’m limited to use Pantheon for some work but not all. Any recommendations on hosting services that will work nicely with the Sage workflow?

I understand the team work/compiled code checks and how is not a good practice! As you said, this is a starter theme and I might modify it to fit my workflow.

You said Sage other tools will make this 1000% easier, in what way exactly? In regard sof me working with Pantheon? Ideally I can create something like “gulp build” and will create a folder with all the necessary compiled files for me to upload to Pantheon, through Git or SFTP.

Thanks for your help!

Mateo

Most of the Roots team recommends running Trellis/Bedrock/Sage on a DO droplet. When you’re running all of the things, Trellis deploys can help take care of the asset building stuff. That’s what I was referring to the 1000%, which might be slight exaggeration.


No need to do this. Just remove https://github.com/roots/sage/blob/master/.gitignore#L3, which will check your /dist/ folder into git, which is what is needed to deploy using Git.

There are also a few deployment scripts that people like @anon66789415 have written that might be a nice springboard: WPEngine+Bedrock+Sage (https://github.com/schrapel/wpengine-bedrock-build)

Not to wake up a zombie thread, but I’d imagine more than a few folks try to use Sage with Pantheon.

Easy Way

The easiest way to get this combo working (as of 2018-10), is that you have to merge Sage’s .gitignore with Pantheon’s custom WP .gitignore. Get rid of Sage’s and merge into Pantheon’s. This is the result I’m using:

# WordPress #
############
wp-config-local.php
wp-cli.local.yml
wp-content/uploads
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/updraft/
wp-content/backupwordpress-*/
wp-content/managewp/backups/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
sitemap.xml.gz
*.log

# @TODO writable paths
wp-content/cache/
wp-content/backups/

# Avoid accidental modification of pantheon.upstream.yml in sites
# created from this upstream
pantheon.upstream.yml

# Packages #
############
*.7z
*.dmg
*.gz
*.bz2
*.iso
*.jar
*.rar
*.tar
*.zip
*.tgz
!wp-includes/**/*.gz

# Logs and databases #
######################
*.log
*.sql

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db
._*

# Vim generated files #
######################
*.un~

# SASS #
##########
.sass-cache

# Sage-theme generated files #
######################
wp-content/themes/mayflower-theme/.cache-loader
wp-content/themes/mayflower-theme/node_modules
wp-content/themes/mayflower-theme/npm-debug.log
wp-content/themes/mayflower-theme/yarn-error.log
wp-content/themes/mayflower-theme/resources/assets/config-local.json

Your first instinct is to get upset because I’ve put vendor from composer into the repo. Yes, this is pretty bad practice but Pantheon breaks Sage without doing it. Again, this is the easy road.

Hard way:

The better way to get this working is to leverage Pantheon’s Quicksilver deployment hooks. Now, I haven’t yet gotten the second way to work but it totally looks doable. Quicksilver is pretty dope from checking out their docs: https://pantheon.io/docs/quicksilver/ (they’ve also got a repo with a ton of example scrips: https://github.com/pantheon-systems/quicksilver-examples/).

I’ll update whenever I get the time to actually build the pipeline out. Maybe somebody else already has…?

Another folk that shared his journey making Bedrock work in Pantheon https://carlalexander.ca/using-bedrock-with-pantheon/