Open stevector opened 6 months ago
Over in that Community thread, Duran wrote
I’ve been asking about this - and I think I figured it out today, so here goes.
This uses “integrated composer”, so, “normal” out of the box Drupal installs on Github.
I’m leaving out some details, but the basics are…
You want to crate your drupal site in the Pantheon dashboard as normal and initialize the site for the first time on the DEV environment. (by initialize, I mean complete the install.php process).
git clone the pantheon repo to your localhost.
Create an empty github repo.
Add the github repo as a remote on your localhost.
Rename the pantheon repo as “pantheon” and the github repo as “origin”, This just simpifies keeping straight what’s “origin” and what’s not…
From here on out you are NOT pushing to Pantheon’s repo, ever… all work goes through Github.
In your project .gitignore file,
But something like this, at the top : https://gist.github.com/alphex/6fba44d6a5f56f3768c6b65632f59caf.
In my project, this is literally the first 6 lines of the .gitignore file.
THEN, follow this guide https://medium.com/swlh/pantheon-and-github-actions-automated-deployments-via-github-actions-c245aa954797 to set up the basic structure of your workflows.
I’ve made some changes based on this example https://medium.com/bluecadet/pantheon-and-github-actions-1b9b1dbd5746
Which I’ve created in these two workflow files.
[gist.github.com](https://gist.github.com/alphex/7351369afd4c871a5a709425724d73c4)
https://gist.github.com/alphex/7351369afd4c871a5a709425724d73c4
deploy-main-to-pantheon.yml
name: Deploy Master to Pantheon
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
This file has been truncated. [show original](https://gist.github.com/alphex/7351369afd4c871a5a709425724d73c4)
[gist.github.com](https://gist.github.com/alphex/471cb459ac4d0857aaa3440268e17ffb)
https://gist.github.com/alphex/471cb459ac4d0857aaa3440268e17ffb
deploy-branch-to-pantheon-multidev.yml
name: Deploy Branch to Pantheon Multidev
on:
push:
branches:
- '*'
- '!main'
jobs:
build:
runs-on: ubuntu-latest
steps:
This file has been truncated. [show original](https://gist.github.com/alphex/471cb459ac4d0857aaa3440268e17ffb)
These two files handle pushing branches to github, which syncronizes them to pantheon in near real time, after the Actions fire.
This will let you create multidevs based on the branches on the pantheon dashboard (or via Terminus) since the branch is syncronzied to Pantheon when you push to Github.
Any additional pushes to that branch, will go to pantheon as well.
You handle your merges in github, and the main branch gets pushed to master.
I hope this helps!
The need for Node.js/Front-end build processes is also tracked in our internal system as FEAT-1179
Chiming in here as the old Pantheon community has been taken down -- I had raised a post requesting a front end build integration using Gulp or some system over there and was directed to this post.
I have had some success with https://github.com/pantheon-se/node-composer to achieve something that is not perfect, but workable enough.
In short, the package linked above will install node and npm in the composer vendor directory and make it available to composer scripts. From there in the scripts
section of the composer.json file you can define a new script to run npm install
and then npm run composer-fe-build
. This example assumes in package.json
there is a script
called composer-fe-build
defined.
As stated, I have had some success with this on Pantheon's platform (I had linked a sandbox site in the old community hub that demonstrates).
Composer allows you to call your registered scripts
as part of other scripts. So if you name your script build-frontend
, you should be ablle to call it from post-install-cmd
by adding a @build-frontend
step.
I could see something like this working well if Pantheon had a custom composer extension that allowed some simple frontend tasks to be added somewhere in the composer extra
section. That could potentially streamline the entire process.
We have a few pages/sections that touch on the use case of managing a site's code on GitHub/BitBucket/GitLab and how to use a build process in between those external repos and Pantheon. While it's not urgent, we likely need to do a clean up to provide a clearer recommendation. Build Tools has been our de facto answer for years, but GitHub Actions is growing in popularity too. I'd like to answer questions like https://community.pantheon.io/forum/t/how-to-use-github-actions-to-syncronize-code-and-compile-your-css-js-before-deployment/272 with a clear link to Docs.
Relevant links: