About Stacks Guru

Stacks Guru is born from the need to search the vast number of videos out there on stacks built for Stacks Pro and the Stacks 5 plugin for Rapidweaver.

We have scraped over 500 videos to get the transcripts for each in order to make the spoken word searchable.

Please use this free tool to help you learn and discover the awesome power that Stacks and the stacks made for Stacks have to offer.

Stacks Guru

Video Reference

Leave a Tip!

Every little bit helps to keep this going. I'll be doing my very best to keep up with the likes of Joe when it comes all the videos he posts!

How to Deploy your Website with Git thumbnail

How to Deploy your Website with Git

In this live stream we will learn how to use git to deploy your website to your Webserver.

Categories: LiveTutorial

Transcript

[Music] and hello everybody
Aloha Tony how's it going bud thank you for coming today oh man we got some
really exciting stuff today um just to get started we're we're not gonna wait we're just gonna jump right into it
today cuz we got a lot of get going for new members I am Joe workman I am the
founder of Weaver space and welcome to my youtube channel hopefully you're gonna enjoy today's talk and today what
we're gonna be talking about is git now it's kind of an advanced subject for
most web designers web developers because it's it definitely is is we're
gonna get down into some advanced stuff we're gonna get into some coding today we're gonna start where I need to be getting into command line and all kinds
of crazy stuff so now I do have to say that this is my workflow I'll try to
point out a little bit where maybe you could do some things a little bit easier or how your situation with your web host
might be a little bit different because I managed all my web servers from command line so I'm gonna be diving into
some really techie stuff I don't have any web interface to manage my web servers I do everything from the server
on command line so where I can I will mention how your hosts hopefully does things a little bit easier for you hey
Martin hey Gunther thanks for joining in today so yeah I'm really excited I'm a
little nervous because we have a lot of stuff to do today now I do have two premise basically what I did was over
this weekend I set up a completely new server I just wanted to you for myself I
wanted to set up actually a new web server that had like all the latest versions of everything and basically
what I thought is well instead of you know me setting up all this you know get web deployment stuff before I was
actually gonna do it live today so we're actually gonna be doing a completely live from scratch get hook deployment of
a web site a very simple website from scratch so I haven't done I haven't done
any setup for this I've done a little bit right I have a couple scripts that I've that I'm utilizing and whatnot but
for the most part we're starting from scratch today and I'm gonna give you a
little bit overview of how how'd it maybe use get a little bit and and some
benefits that you might like with it and some gotchas so without further ado
What is Git
let's jump on in let me go ahead and share my screen and there we go okay so
I'm new stringing setup I thought I'd try something new today got like me over here on the side and all the desktop over there I don't try something new try
to didn't cause it improvement hey Peter thanks for joining in today I'll move the live chat off the screen actually move that over there okay um so
first thing we want to do is actually know what let me back off a little bit so one thing I want to talk about a
little bit is what is git okay so git is
a version control system now me and Gregg did a podcast it was three or four
weeks ago checking over on Weaver radio comm there's episode 28 ok and in that
show we talked about basically what I'm gonna be showing you today and essentially people you know wanted to
see the video version of that podcast show because it obviously is the very visual thing so that's what spurred all
of today and but what is get it is essentially a version control system
that now it's text base so you can basically if you publish a website you can easily roll back to like you could
see all your various versions that you've deployed you can easily roll back to a previous version stuff like that so
um it's very easy now from a developer standpoint we use it to like you know modify code files and that's the origins
of get right it's for like development actually like you know writing code for apps and websites and stuff like that
and it's beneficial for us developers because we can see exactly what lines
changed and maybe we can merge some stuff together from an old version to with a new version and you do all kinds of stuff no
I'm not I'm not gonna dive into any of that today um and to be honest I don't think any of that is really relevant to you guys as
just designers who want to maybe version control and and tag particular moments
in history maybe you want to easily roll back to different states okay we're gonna look at the raw basics of get
today I'm not gonna go into any sort of advanced like how you can do dips between files and merges and not gonna
do any of that and to be honest even for myself I use get to deploy my websites but I never really used those features
of git on my websites at all like not at all I use it my day to day development
when I'm writing apps and stacks and stuff like that but not for website development so git is just again it's a
decentralized system of managing your codebase in this case a website okay and
I say decentralized because what it is is you have you can run git on your server and all of our Mac's have get
installed by default so that's cool and what we're gonna do is we're gonna set up a online account um today I'm
going to be using git lab get lab calm now um I do most of my stuff on github
but to be honest I I kind of wanted to test out get lab so I'm gonna be moving some of my my projects over get lab
mostly just to test it out um it's a new kind of a spin around for a few years but it's kind of the new hot service
right and it looks nice so I'm gonna be setting up a new repository on get lab today and we'll be integrating that and
for those of you who might want to use github github is huge I'll I'll probably show you maybe how to set up like the
get hooked stuff in one of my github accounts when we do all the the deployments so there we are I just want
Getting Started
to give you a quick overview of what git is what you can use it for um and now
let's dive in and actually get some work done okay so start off as I said and I
haven't done anything so we're gonna go ahead and I'm gonna go over to get lab calm right now and where's my
Safari window okay here we go I am going
to go to get lab and what I'm going to do is I already have some project set up
here but what I'm going to do is I'm gonna set up a completely new project okay oops gestures okay I'm gonna set up
a new project and what I like to do is I call the name of my project when I'm
doing it for websites right it's the name of the actual domain so I right now we're gonna be testing a website or
publishing a website called aspect hq.com okay so that's the name of my project
it's the name of the domain there's no that way there's no confusion on what the heck this is it is for
aspect hq.com because that's the website we're gonna be working on today and I'm gonna say great project boom okay so
we're kind of done on that side fun times now what we need to do is we need to
clone this repository locally on our Mac okay now I use a app called Tower I'm
gonna just say it's I think it's get tower yeah Tower calm Oh tower
ah get
yes I use this software um well get started it's free
really oh wow that's crazy that must be new because tower is probably the best
git client I think out there um kind of crazy it's free now what the heck I spent like 50 bucks on it or something
like that um oh it's yearly now okay I think I use the basic license um me I'm
not sure we can get with a free package but anyway tower is is an amazing app it
probably is a little bit more I'll be honest it's probably a little bit more than some of you might need I used to
use an app called get box before I got really good at version control ingot so
take a look at get box it's a little dated it's on the App Store it hasn't been updated in quite a while but I know
it still works and it covers all the basics maybe after after we get
everything working today 5-time may be all loaded up in get box and we can kind of see how things are but for right now
for today I'm going to be using tower I didn't have I was gonna use git Box
today to show you how everything works but I've I didn't have time to set it all up and kind of relearn how git box
works so inside Tower what's kind of cool is you can i've already integrated it with
Cloning Git Lab Repository
git lab okay so our log din and if you notice the repository that i've already
that i just created on git lab is there so what i do is i gonna say clone and i'm gonna select a different destination
here that's fine let's just put it right there okay so I'm gonna say clone
now let's go to find her where's my
development data element I spit various okay so here's the folder now anything I
put inside this folder will now be version controlled and so you rehab here
in my repositories we have aspect HQ comm okay so uh let's go ahead and let's
just minify some of these windows and I have already created a very very very
very very simple project that we're going to publish to aspect HQ comm so if
we just preview this just a really simple web page um that's it this is what we're gonna be working on right now
um so what I can do is let's just go ahead and let's go to the publishing
setup I haven't even done this yet um let's see HTTP actually we're gonna do configure manually and what we're gonna
do is instead of FTP it's gonna be local folder we're gonna choose the folder
we're gonna choose it from the folder that we have our development aspect HQ
comm there we go okay so here we go remember that is the the folder where I
cloned the git repository from right so again we cloned the git repository this
folder I'm gonna publish to that folder we're not publishing it to the server we're exporting it and basically with
rack Weaver let's just say oh cool all that local the address is HTTP
www.andhramirchi.net ination
we published it locally and if we go back and here we noticed inside that folder I now have
my website right I have the sitemap I have the index file all that jazz here's my website cool so now what do we do
let's go into tower and what you'll notice is inside tower or whatever your
Staging Commits
gate client of choice is you'll notice that it has found all these files now it has question marks here because it
doesn't know what these files are right it's like I have no clue what these files are they're new so what we need to
do is and get what we need to do is we need to stage these files right so we
staged the commit so right now what now what you can do is if you wanted to just save each one you can click on each one
or you just say stage all right so what this is gonna do is I'm gonna say and then for every time you save or commit
it's called a commit you whenever you commit something into a repository you have to type in a message alright so
make sure this is something this is something for you right all this is for you so um all right this one's probably gonna be just be something simple like
initial commit okay but you need to be able to make notes so that when you
refer to these later on okay you know exactly what you did right so and you
can put so the this particular the actual title of the commit think you know it can only be like 50 characters
or something like that but this detailed description if you really want to you know detail out what changes you made
and what not you can detail it all out here okay but these these commits are very useful because later on if you need
to revert to something you need to be able to look at your history and know what you did to know what point you you
need to go back to right so I'm not gonna add any detailed description here um I'll admit I don't add detailed
description too often mostly my titles enough I put in enough information in the title to let me know what I need now
so we've committed that and this is all blank because that we have now no changes so we need if we go here to
master will see that here is my commit right so here's my initial commit and here's everything that we did in that
commit and it has a bunch of added files okay now what I need to do is I need to
save this right now all changes are only on my local Mac okay
but remember we created that repository online on gitlab so we need to push that
and that's exactly what it's called it's called it push we need to push all those changes up to get lab let's go ahead and
click this little arrow and it's saying because it's the first time I'm ever actually publishing something say do you
want to publish this branch say yes and what it's doing right now is it is
connecting to get lab it's pushing all those changes up and while it's doing that let's go ahead and open up a new
Safari window oops and let's refresh and boom so I
refreshed this and if we look we have all of our files here online and it's we
now have our very first commit inside get exciting very very cool okay so
let's just continue our quick tutorial of get really quick go ahead and I'm
gonna go ahead and bring back up our rack weaver project and let's just add
let's just add a little bit of content here okay I'm going to go to the foundation paragraph
okay just gonna do that and then I'm gonna publish this those changes locally
okay cool so now what we're gonna do if we go back
to tower now if we go to back to tower we'll see in the working copy we have
three and that's because it's notice that we have changes now okay now now if
we if if you see it has these little M's that means that file was modified okay
and if you click on it you can see actually the modifications so this CSS file some reason there isn't there's an
arrant space added and the index.html you can actually see all the changes that happened now chances are we really
don't care because we just want our site to look good and what we see in rapper Weaver is what we get right so and then
we have our site map which basically changes the modification date when the when the page was modified it right
so what you do is we could just say you know added caption to title something
like that right and we can commit that and if you look at master it says it has
What to Avoid
this little head and little arrow and that what that means is that hey I have
one pushed I mean I need to push something up to the server we're not in sync with the server so I'm one I'm
going to go ahead and I'm gonna go ahead and push that and if we go back to the
server sorry okay go back to Safari and if we
refresh okay well we won't see we need add any new
files but all the changes are now synced on the gitlab so really cool stuff there
okay now what are some things before I
start diving into setting all up all the the deployments and all that fun stuff
what are some stuff that we shouldn't be adding what are some stuff we shouldn't
be adding to our gate repositories is primarily a text-based thing right so
I personally wouldn't like it it doesn't handle large really large files very
well okay like video files essentially are really really large images probably
not a great idea okay um so like if if you're using rap Reavers resources um
you might want to think rethink that if you want to use this get deployment and and you have like video files and stuff
like that and unoptimized images right so you're gonna make sure that you know
images are fine you know drag and drop images and rap you or if you optimize your images and put them in the resources that's okay
I would definitely stay away from video files unless they're like really small video files like less than a Meg or
something like that right um outside of that outside of you know those I would
definitely consider if you want to do videos and self hosts those you know actually create you know a subdomain or
another folder on your server that you warehouse and and just reference those okay now there are some other things
inside yet actually I mean I just thought about this there are some files
that you might want to ignore okay so inside ignores okay um there are open
in editor oh there it goes okay so in
get you can ignore you can tell it to if you see a file that's named this ignore
it and don't try to version control it okay um some very common ones that I
recommend you do is dot d s underscore I think it's store oops okay if you know
those are pretty much like common like Mac files right you'll see those in a Mac file system another thing you might
want to ignore is something like error underscore log that is a PHP a lot of
times PHP if it has an error on the server um it'll create this log file and you don't want a version control those
log files you don't want yet to think that that's a you care about some AC you're gonna put in a bunch of files in here now if you
wanted to they're kind of what got me onto this oh shoot I'm not sharing my screen hold on Oh bad Joe bad Joe okay
um sorry let me back up a little bit um
here let me clean up these windows okay sorry about that let's go ahead and back
Git Ignore
into time in tower right now but in any get client you can you can set up with
something called a git ignore and I'm gonna open that inside the editor here and basically what do you do is it's
just a plain text file that you put in files that you want to ignore okay now
let's say for example I wanted to manually have a warehouse folder on my
site on my server what I could do is let's say I tend to use a folder called Depot right what you can do is you would
put that the name of that folder in this get ignore file so that when it saw it on the server it doesn't matter what you
throw into that Depot folder it will just ignore it okay so this gate ignore thing is is very
important I think the gist or I think it's all caps actually yes okay okay so
it's des underscore store so we want to definitely ignore des underscore store I
recommend you ignore error underscore log again that's the PHP files so PHP
adds an error log in your server get on the server is just gonna ignore it and then depot that's going to be our folder
that we can utilize for warehousing now if you're a CMS user total CMS right
you're gonna want to do CMS underscore data as well and if you're in the future if you're watching this in the future
you'll use T CMS data because that is the CMS folder for total CMS - okay so
really good tips you want to make sure you ignore those because it's just gonna ignore all that stuff on the server and
you can manage it manually all you want okay good stuff there um I'll actually
save that and if we go to working copy its see that we might do we added to get
ignore file so we just say add and um ignore or some stuff okay and we're
gonna push that up cool
okey-dokey so now for the fun part I kind of had a lot of that baked up um
obviously I you know clone your repositories I do that a lot so that was really good um we're gonna set up they
get hook stuff now so let's let's talk
Git Hook
about how how all this works so this is how the entire workflow works for using
git to deploy your website you do everything that we just did you make your changes you publish it into a local
folder and then inside your git client you you save those changes you type in your git message and you push okay now
when you push to the server this is this is now what we're gonna start automating okay we're gonna it pushes it up to get
lab comm what we're gonna set up right now is on git lab comm it has something
called I think they call it integrations actually the technical term is called the git hook okay we're a web hook and
what that does is you we can put in a URL into our repository on git lab that
says whenever we push something to you go ahead and ping this URL so we're
gonna give it a URL okay and what that URL is is a file that we're gonna put on
our server okay and basically what that's going to do is whenever get lab
pings that URL on our server that URL it's gonna be some PHP is gonna say hey
I know that git lab just pinged me that means I need to go pull new data so at
that point get lab pings our server our server gets the message from git lab and says oh thanks that must mean you have
new stuff for me this server is then gonna pull that data down does that make
sense okay so again get labs sends the URL request on our server we're gonna have
some really cool code that gets that request from git lab and says hey cool I
got new stuff I'm gonna pull it down with with a git command now obviously
hopefully you know your hosts has get a lot of you know decent hosts
will have get installed and I think you can even configure inside cPanel I'm pretty sure I listen to the episode with
Greg obviously Greg runs chillydog hosting and I know all of this works on his services as well so yeah so right
now what we're gonna do is let's go and jump back in to get lab ok ok so inside
Aspect HQ
get lab I'm inside my aspect HQ calm and what we're gonna do is we're gonna go do
settings integrations ok and inside here we have push events ok
this is gonna be a URL that it is that this is actually gonna pull down ok this
is the URL that we're gonna hit so what we're gonna do is I'm gonna create this URL doesn't exist yet but we're gonna
we're gonna create it we're gonna do WWE aspect HQ aspect hp.com slash employ PHP
ok so we're good this deploy dot PHP file does not exist on the server yet
but you can we're gonna create it in a minute but we're I just want to get this all set up so here whenever we push to
get lab now once I save this can't fire
the valid URL
Oh see I should have tested this beforehand
[Music]
see this is where it's gonna bite me okay we have to give it a secret token I believe hold on one second I can't have
a blank you are well the valid you okay
we're gonna boom fun stuff okay let's figure this out I assumed this was going
to be as simple as it was with a get luck github it's different QuickBooks
are used behind callbacks fun times
mr. silver maybe it's this older occasion I know it's I'm gonna turn off that's a cell verification I just want
it just a ping that that's the ad word damn URL can't be blank
okay web hooks are used to find HTTP callbacks yes I know what a web hook is use cases
integrate hooks endpoints if you are writing your own one-point web server
they'll receive the web hooks keep in mind the following things your endpoint should receive HTTP responses that as fast as possible you wait too long give
up over the side to it anyway type it yes should always return a valid HTTP
response you not give a that's fine
ignores HTTP status code returned by your endpoint fun times fun times okay
instead of wasting time trying to figure out what we're going to do and figuring this out we're gonna go over a github
since is this it's a system that I already know to you how to use we're
going to go ahead and
rats going live on Times
I just had any remote
what I'm gonna set up really quick is a new repository here
I suspect HQ calm and we'll just make it
public for night now okay posit Ori I'm
gonna do the same thing we did at the very beginning because I just want this
to work really quick fun times go over here we're gonna clone this
we'll just call it the holder fine okay open show it and finder sometimes then I
go to element and I'm just gonna copy
the data that's in here we're gonna go into here copy that into
their cycle and we're gonna stage all of these and we're gonna say initial save
it publish it up to github
boom okay so now we are ok let's refresh this Oh excellent
so now I can go in - sorry about that so what what I did really quick was I've
Webhooks
just basically replicated everything that we just did earlier um and yeah so
what services has been deprecated oh what a webhooks yeah had a web book
okay cool here we go so here we go
now inside github we're gonna go to web hooks and you paste in the URL so we're gonna put in our URL slash
PHP and we're just gonna I'm gonna do
application JSON because that's what no we're gonna do X form that we're in do that secret just do my secret okay and
you're gonna do on the push event so whenever we push to github it will
automatically ping that URL so you can say add web hook not now had an error
because that file doesn't exist yet okay so what we're gonna do right now is
we're gonna create that file
Deploy PHP
so what we're gonna do is on here I already have a set of files that I use
and here it is so we're gonna create this deploy PHP file really quick let's
review it okay so here we have very
simple PHP we say if the request is post so to kind of back up a little bit
there are multiple types of HTTP requests and all get hooks are a post
request that means even if you hit this this URL via the browser it doesn't matter because that's a get request um
this is a special type of request that's kind of programmer e right it's basically like when forms get submitted
and stuff like that it's a different type of request it's not just something like putting a URL in the browser window
okay so this is a post request that gets sent to the deploy PHP and we want to make
sure that it's only a post request so that people just can't hit this URL and then you know it's gonna trigger our script all the time which shouldn't
really bother anything cuz it's just gonna pull if there's no changes it doesn't pull anything but um we should
just be thorough and we're going to verify that um this is the post request and at that point what we're gonna do is
we're gonna look for a file we're gonna say the file that I'm gonna look for is home Jay workman deploy hooks aspect HQ
comm slash deploy if that file and then basically what we're gonna do is we're just going to create that file and we're
going to send the data that github sent us we're gonna print it inside of the file okay so that's that's all this does
so that requests all it does is github will ping this deploy PHP file and then
at that point it's going to if it gets pinged it's gonna create a file and that's all it does just creates a file
then okay then this is what kind of where some techie geeky stuff happens we're gonna have a cron job which is a
routine scheduled job that looks for that file you know we can run the job every minute every five minutes however
you want okay so we're gonna we're gonna run that job every you know I normally
do every five minute um and if that file exists at that point we're going to then initiate the pull
okay now the reason we have to do it that way is you cannot execute Shelke
fans okay you cannot execute get pulls from within a PHP script it's just security warnings you just can't do it
um it's not recommended at all so every every host that's worth their weight in
anything worth anything will not allow you to do that because that's huge security holes for hackers and all that
jazz right so the PHP is just going to create a file and then we have a shell script
here this is the shell script that I use and basically what we do is inside this
shell script um this is the script that we're gonna use to schedule and it's gonna run every X number of minutes
however it'll however often you want and it's going to look look for the file if the file exists it basically renames the
file it appends the date time stamp just so if we ever wanted to look at it in the future how many times everything happened and whatnot you don't really
you could probably delete it if you wanted to um you know I just move it then basically what I do is I CD into my
website directory then I reset do a git reset which basically means it will if
there are any changes law on the server in theory there shouldn't be any changes it's gonna reset back to the reverted
version or the version that it thinks it should be and then it's gonna do a pull and it's gonna pull the data from our
server okay cool it's a good stuff there so let's go
Deploy to GitHub
ahead and start doing that so what I can do is I'm just gonna say reveal in finder and what I can do is I'm gonna
take this deploy dot PHP file I'm gonna copy it into this directory okay so not
we now have a deploy dot PHP file and
that's all we need for now we're gonna bring up tower and I'm going
to commit this the boy script and I'm
gonna push that up to github okay now
the fun starts we're going to now we're going to go on our server okay so this
is where we get into the really geeky part of today because as I said early on
I manage my web servers and terminal this is how I manage my web servers from
a terminal from command line and yes it's a key um you guys hopefully have a
great cPanel and some great admin interface that lets you do everything that I'm about to do from command line
but hopefully maybe you'll learn a little bit okay so I'm gonna go into my
directory which is websites aspect HQ calm okay
and fun times actually an interesting thing here is that I now need to UM
actually I'm gonna remove that index file because that was just me testing that the domain actually worked ok so
now I'm inside my aspect HQ comm folder and there are no files in that directory
this command I'm not gonna explain every command that I run but there are no files in this folder now what we need to
do is we need to do an initial pull from github ok to get all of this working now
this is interesting I wasn't planning on doing this today but now that I switched to github it's probably best for your
benefit is I need to set up authentication with my server and github
ok so fun times
ah wait we're gonna close up gitlab that was a fun experiment for a few minutes
okay so inside let me back up now a little bit so what there is a if you're
What is SSH
all probably familiar with something called SFTP right secure File Transfer Protocol okay now that is piggybacks on
something called SSH which is secure shell it's it's actually how I'm connected to my server right now it
allows you to to remote you know connect to things okay now
SSH is a strong secure industry standard across the entire world for
communication between devices okay it used to if you want to go old school it used to be something called telnet
highly insecure telnet is the same thing as like FTP kind of you know if you're
if you're comparing SSH is the FTP as telnet is to FTP okay telnet and FTP suck ssh and SFTP rock
okay so ssh has something called keys and what's kind of interesting is that
what you do is you can set up keys on various devices so i I have key set up
on my Mac Pro here on my macbook pro and on all of my servers and what what you
can do is if you know what those keys are you can save those keys inside services like github and get labs and
things of that nature so when you go to pull things um instead of having to type your password every single time
basically what you do is um it uses the keys and it says hey I see you have this
public key it's gonna compare on get flat on get lab or github do I have
access to this public key yes I do and it's gonna allow that communication 100% secure as well so that's really
cool um I will show you how to do that obviously these are my live production keys so when I go to page two those keys
into place I am going to have two unshare my screen because I don't want those broadcast to the world
because then that would obviously negate my security so let's go ahead and I'll
show you how to set this stuff up I was employment doing this today but I guess it's kind of to your benefit I
guess kind of fun stuff I'm interesting so um inside get lab our get lab github
Get SSH Key
we're gonna go into my settings we're
gonna go into security okay and oh no I
forget where github
okay this where we gonna do so inside your repository and you go to deploy
deploy keys and you're going to type in so this is going to be you know my
server is that's just a name it doesn't matter and what I do is I'm gonna get my public key for my server okay and I'll
show you how to access that okay and then I'm just gonna paste it in here and say add key okay so I'm gonna move this
off to the side really quick I'm on my server we're gonna go to my home folder
which is home Jay workman and there is a secret folder now this secret folder
exists on your Mac as well because your Mac is running Linux so we can go to a dot SSH okay and if we look inside this
folder you'll see that there are some files here okay and this ID underscore RSA dot pub that's the one you're gonna
get the contents of that okay and you're gonna paste it into github hey now in
order to generate those files you would run the command called SSH - he SSH key
Jen okay I'm not gonna run this right now cuz I already ran it but basically you're gonna run SSH key Jen and then
you're gonna enter in a few answer some questions it's gonna generate these files for you okay so I'm gonna go ahead
and turn off my sharing really quick and at this point what I can do is I'm just going to copy the contents of that dot
Copy to GitHub
pub file
and save that into my github account
Oh
okay let's go back okay so now I have my
deploy key set up in github and if we go
Clone URL
back to github okay and you go to clone okay what this will do is um so it'll do
we won't actually do use SSH and it will give you the actual URL that we want to
clone okay so I'm gonna copy this and basically what I do is I'm gonna go into
Copy URL
where am i and we're gonna go into websites and how did you get clone and
then oh and then do you want to accept yes I want to give authorization and
it's done oops I needed to do if we go into you
notice when you did a git clone it it basically moved it it actually created a
folder in aspect HQ comm called aspect HQ calm so what I'm gonna do is I'm just going to quickly move all the contents
of that folder back so I'm just gonna go
here I'm gonna do move star okay
okay so now and then I'm gonna delete aspect okay well okay so now we did that
git clone it cloned everything down from github and we I now have actually let's
go ahead in theory now if I go to aspect HQ comm boom there's our website oh I
didn't send her text I didn't send her a line that okay so that was a lot of work
to kind of get it set up but now it's it's all gravy I make changes publish it
okay push and then pull okay but now we need to set up that cron job okay so we
need to set up that cron job that will whenever I push changes up to github
okay we want those changes to be automatically pulled down okay so let's
Deploy Hooks
go ahead and that if we go back to our project settings in github and go to web
hooks let's just edit this really quick I say update so it tests it again
mm-hmm I'm gonna do this for fun I'm gonna delete that we're gonna recreate
it really quick I had to look boom okay
so yeah so there we go we got that little green checkmark so the delivery was successful okay
and just for fun if we go into okay now
if we look at those files that we created okay so this what did remember
what it does is it creates something called it's going to create this file
home Jay workman deploy hooks aspect hq.com deploy now this is outside this
folder is outside of my public HTML it's outside of my web folder okay and I did
that on purpose so let's see if we go back to my home so now we are inside
home Joe workman okay I actually need to create this folder um it doesn't exist right now so I'm gonna create deploy
hooks aspect hq.com
okay so now I have deploy hooks and if we go into deploy hooks and look in
there we'll see that we have aspect hq.com and if we do if we look inside
aspect h2 or calm it's empty okay so right now we're gonna do is
let's go ahead and make a quick modification to our project
Rapp Weaver okay now I remember I changed that I'm actually gonna edit my publishing settings really quick and I'm
gonna change the directory to where this is because we changed it a little bit
and that's just gonna be that one now [Music]
here let's let's fix this text right we're gonna go into this paragraph and
we're gonna make it centered and I'm gonna publish boom okay and then now
what we need to do is we need to go to tower okay tower notice the change we're gonna
commit this and say centered text now
what should happen when I push this because we can figure that that hook on github it will see that I did the push
and it should automatically hit that URL and when that hits the URL the file
should be created inside this folder okay if everything goes well that's
Troubleshooting
exactly what's going to happen and yours crossed I'm gonna push this it's
thinking about it boom it pushed okay so it pushed that to github fingers rolled and should
[Music]
hmm interesting
sometimes troubleshooting
mmm interesting I didn't that work okay
so if there's a request post file [Music]
hey what I'm going to do is let's test that this works so what I'm gonna do here is I'm just gonna air let's bring
up transmit something maybe a little bit more familiar to you guys and I'm gonna
connect to my server here we're gonna go
into websites I'm gonna edit this file
in line right really quick okay so I can
do right now is I'm just gonna comment these files out which basically means this file will get created any time this
gets hang just for fun and what don't
you do is in this URL here I'm going to do so now in theory since anything that
hits that that will work if we go into boy hooks aha
I did not work
mm-hmm I know why I know why okay we're stupid file permission issues okay
we're gonna do is we are going to do I'm
gonna change the location of this file and I'm actually going to change it to be web sites slash aspect hq.com
okay so the reason that didn't work is the way UNIX works is that the web
server is run is ran under a particular user right most time it's a user called
WWWE - okay um obviously I'm logged in as Jill workman um now in my home folder
just as on your Mac as well only I have access to my home folder um so when I tried to create when I tried to write
this file into home Jay workman deploy hooks blah blah blah okay it tried to create a file inside my Jill
working directory but what I what I need to do is I need to create that file inside though the public folder where
the website is hosted where WWB data actually has access to create new files
okay so I can do is I'm gonna just gonna create a file here called home Joe
workman websites aspect HQ comm deploy hook now because this this folder here
um is actually accessible by the the process that runs the web server it can
Deploy Hook
create this deploy hook file so we're gonna call this deploy hook so I'm gonna
go ahead and just for fun I'm gonna save this and then I'm gonna go ahead and run
it and actually if we go into here you refresh this
what I'm gonna do is I'm just gonna say file the full hook and what that will do is that will actually create here we go
this is even simpler it will create a deploy hook file in the same exact folder that this deploy PHP file is in
so let's go ahead and refresh that okay
there it is okay there we go making progress okay so now whenever we hit this URL um it's going to create
that so it's Gordon I'm gonna delete that file and now what we need to do is I made these changes locally on the server
but we're going to have to do is we're gonna save this in our repository
don't say okay out there okay oh this
isn't the code so remember inside a finder we go in to remember this is
where publishing we're gonna have to update this file this deploy dot PHP okay so that's this file here paste okay
okay there we go and we go to tower and
we're gonna deploy this again so remember I made a quick change to this file we're gonna save it
oops I mean I mean put on my commit message duh fixed beep boy okay enter
this is a news this is a new server setup I have this server set up a little bit differently how I have an existing
one so sorry for the troubles but hopefully maybe you learned a little bit okay so we pushed that that new deploy
file now in order to get it on our server or going to have to hang up to it
let's see where am I websites expect HQ calm okay
so here we are what I can do is I'm gonna do a git pull up okay so is
interesting I did a get pulled but remember I actually changed that deploy dot PHP file locally here and get saying
whoa I can't do a pool because you have changes locally on the server that's a no-no so that's where we do this guess
reset - - hard head okay and on so
basically I reset all the changes that I did to be the the you know before any
changes were made that's what that command get reset that does and now I can do a git pull and
there we go okay so now now our deploy
should work fun times and actually it won't work if we if we do this because I
put back in that post check okay so
let's go ahead and make another change
there we go yeah I mean there's just something simple I'm gonna paste in another
paragraph and we're gonna publish rudimentary change okay remember we need
to go to tower and if tower go here and say changes commit
push push head-on times
okay so now now that that push is going up okay
github should have got it and it should have deployed or actually and close that we don't need github anymore
drumroll but we should have a file called deploy hook here and boom we do
so here we have a deploy hook and now what we need to do is we need to create
that scheduled job that looks for this file and when it finds this file it's
going to do basically the pool from github okay so I already have a version of that
file on my server let's look at it
really quick again because we are gonna have to modify it slightly because I I
changed the directory where that file is located so websites and was deploy - hook - hook
okay and actually what I can do is I mean to be honest in all the years that
I've actually used this workflow I've never looked at these files so what I'm going to do is I'm just gonna say remove
dollar hook I'm not gonna even save it and then what we're gonna do is I'm
going to so now what we're gonna do is so now what this script does is it it
has our hook we're looking for that this deploy hooked on aspect hq.com if it finds the hook it's gonna delete
it and then it's going to go into the directory and run those two commands that I just ran it will do the reset and
then it will do the pull okay so so that's exactly what this does one of you
is I'm going to copy this and I'm just gonna go
okay why don't you do is I'm just going to create a a file here and we're gonna
call it check holy Sh
okay and that's the file that's the same exact file I just copy and pasted from
from the Mac App the vs code and I need
to make that executable okay so now I
can execute that just deploy script so if we wanted to what I can do is I'm going to I'm just gonna run this deploy
Sh just for fun and what we'll notice is um
it actually ran so it found the deploy hook inside websites aspect a ChiCom um
it removed it and it did a pull from github pretty cool right so yeah pretty
slick stuff right there so if we go into websites and aspect HQ comm will see
that that deploy hook got removed and the files got updated if we look at the
timestamps here they have been updated okay it's pretty cool um let's so let's
schedule this job now so now hopefully your host has a way of scheduling all of
these jobs these scripts actually you know in your cPanel I know there is I'm
gonna use something on here called crontab so I'm going to do crontab - E
and I'm gonna do is let's see crontab on
every minute I think it's run every I just get the crontab run every minute
okay so um it's when I do is Randy star star star star star slash home slash
show workmen slash oops
what was the name of that script did I call it
check-check the boy dhatus h-hey so now
I'm gonna run this check deployed Sh every minute and I think every minutes a
little aggressive I'm only doing that for this demo I would do it at most like every five minutes I think on my servers I do every
15 it doesn't really matter I guess every five minutes is fine yeah probably better if you want things
updated a little bit more frequent but and it's not really it's not a horrible thing if you run it every minute I mean that scripts gonna run like like
lickety-split if the file doesn't exist it's gonna do nothing it's good to know it's gonna exit so it's not really that
bad most hosts won't let you run stuff every minute though so um if you're scheduling jobs inside cPanel chances
are they limit to you i would say maximum they'll let you run something's every five minutes some maybe only every
15 so yeah keep an eye on that so now that job's gonna run every minute and
what we should do here let's go ahead and let's look at Safari really quick
Keep Calm okay so here I've aspect HQ calm and what we're gonna do is now that
we have we have everything we're done we have everything set up and what we're gonna do is I'm gonna remove this second
line because obviously we don't need it so I'm going to remove this second line of we are a cool company we're gonna
publish that up to github via tower and then hopefully within a minute our
website should be completely updated fingers crossed let's go ahead let's do
it nervous so I'm going to go in here and then
delete that save our project we're going to publish it locally published it we
need to go into tower and tower notice that we had changes and we said yep we
agree with these changes deleted paragraph okay we're gonna push this as
soon as we push this drumroll that github will see that we pushed it will
ping our deploy script our deploy script we then have a crumb that our deploy
script will create that file that deploy hook file at that point our cron job
should run that runs the script that checks for that file and if it finds the
file it will remove it and then pull down all the changes seems crazy but
hopefully hopefully this is gonna work I
guess a benefit of not removing it probably what what I should have done is um yeah because I was removing that file
um a benefit of not removing it and just moving it um is actually you know like
you can actually see it run because you have validation that it actually did something right
so maybe we can we can add that afterwards but here let's just gamble see if it works already and there it
worked so we saw that line was removed it all works it's all magic right pretty
pretty cool that's pretty magical and of
course dogs work
dan dogs okay so pretty exciting I'm
gonna look at the chat box because I've been I have been ignoring it pretty much the entire time hopefully you guys got
got some stuff out of that let's look at this chat box really quick see if I can answer some questions
I wasn't sure yeah for a while I wasn't sharing my screens sorry about that
Gaston says even though my tutorials clear it seems complicated yes I'm setting it up as complicated but as
you see from now on you know once you get it set up though it's just a
well-oiled machine right and it just kind of I'd it locally pushed it up to
get magically showed up on my server yes and I warned you at the very beginning this was technical this is complicated
um to get it set up it is very complicated but it is very interesting
right and some benefits if we ever wanted to roll back to a commit here
let's actually do that what I do is I'm gonna roll back the commit that we just made um and I'm gonna put the two the
two sentences back right um so let's go ahead and do that really quick so this
just kind of shows us what we can do is um here I am in tower if I go to master okay so here is where I deleted the
paragraph okay I'm gonna revert this change right now um so I'm gonna say
revert okay so now reverted that I'm gonna push this back up to my server so
I I'm pushing the these changes up to the server and they're done they're pushed so in theory right now again
right now what's happening is github got the push and it's hitting my server and
[Music] we're going to and look it's already
done right so we have those two sentences back right so we do get
benefits from get right so it is yes it is a it is a complicated
set up but once you have it set up it's pretty simple so yeah sorry sorry Gaston
um this isn't you know why is this better than rap we were publishing well I just
kind of showed you the version control is very interesting right um it it also
you know some people are plagued with FTP problems or you know issues with you
know whether or not things are getting published properly publishing locally is
fast right super fast and then you know
yes you get the benefit yes you have to type in the commit message and commit and then you push it up to github and
then github automatically pushes it down so it's a little we're kind of going around about way but it works really
well and you get that version control history so if you ever messed up and he
just oh man whatever I published how many times I've heard people say they published something and they didn't
preview it and they're like oh shoot I wish I just want to go back to what it wasn't last week well now you could just
go to get revert to a previous version push that back up and your servers fixed
right some pretty cool stuff
now gasolin says I do that oh he does version control basically by making
changes in duplicating his wrap weaver project file yeah that's true now what I didn't actually mention is
you could throw your wrap Weaver project inside your github repository as well inside your git repo okay so basically
if you are you know now I recommend right now I'd recommend creating a separate git repository for your wrap
Weaver project okay so that way you know your wrap your project has its own
repository in your website you know the actual exported website has a different one there's a lot of reasons for that
and also with rack Weaver projects if you throw that and get the changes are
gonna be very obscure okay um you cannot look at what it changed you just have to
kind of blindly accept the changes and save them okay and but you can you can
roll back to previous versions of it works so how do you get your
rapidweaver back to them back to that then I'm not under I'm not understanding
the question of that now I I do want to say Joe this is cool but what about like
testing like this is kind of you know let's say I want to I want to test something out how can I you know how can
I test it out um now I'm not gonna I'm not gonna take the time to do that that could be a whole nother live stream
maybe I do that next week is essentially what I would do is I would for a testing
purposes I'd create a test subdomain like a little test stop aspect hq.com um
and at that point what I would do is I would publish traditionally inside
rapidweaver to that domain so then I could publish all I want to this test subdomain from rapid eevr an inside rep
you can you can have multiple publishing destinations so let me quickly show you what I mean by that
so essentially inside rapidweaver let's go ahead and close out some of these other windows on the inside rack weaver
inside your publishing um setup okay um this is let's say this is let's rename
this to be production okay what you do is you could say add new destination and
then the destination here would be HTTP you know testing dot aspect hq.com you
know user names Joe workmen and password who knows what that is okay but you
would set it up normally yeah I know it doesn't work so basically what you do
here is you would say this is testing okay and what what's cool about this
method is you would set up your testing server here to use s to use SFTP or FTP
whatever is your default publishing mechanism and then when you're happy with all the tests what you do is you
then publish to production and then you do your whole tower github integration thing right um so what's
cool about that now if you've never done this you'll notice up here we on the publishing button inside rapidweaver you
now can swap between production and testing okay so you can you can swap
between different destinations so again when you're in testing you could hit the
publish button and then at that point it will publish up to your server and then when you're happy with all of that and
you're happy with all the changes you think think everything looks good you swap back to production and then you
publish and then what that would do is that'll published locally to the local folder at that point then you use tower
or your git client to push that up to the server and all that stuff we just learned today so that's a pretty cool
workflow um that's the workflow I plan on using on for Weaver space so I'm going to be I'm gonna have a test server
that allows me to kind of have development and you know test new things and try new layouts and stuff like that
and then when I'm happy I will publish it to production then that will then the version control at all and push push it
over to github so anyway guys I think
that kind of wraps everything up I don't see any other further questions um again
this is definitely a difficult set up right even I stumbled through a couple
things right as we were doing it um you know getting things set up and I sorry
for the thing I was trying to use get lab get lab works a little bit differently in the github I was experienced with how github works I was
testing out get lab I thought it would be just as smooth but yeah I swapped
over to github and hope luckily it was all smooth gravy after that I will
definitely post inside the show on the show notes for this later on by the end of this week I'll have the snippets to
the scripts that I've used so you'll have the PHP deploy script and the shell script that I use I'll press publish um
you know them on github so you can you can access those really easily so that you can use those in your setup yeah and
I know I probably scared you guys with the the terminal and how I use things
unfortunately I don't even have a web server that uses cPanel which is what you guys use most likely so yeah you're
gonna have to figure some of that out so there's some legwork that you need to do on your own in order to figure out how
to get the scheduled jobs and the integration and stuff like that from cPanel I know it's possible because I
talked to Greg especially on that podcast again episode 28 on you can get Greg's perspective on this from the
traditional hosting side but yeah I hope you enjoyed this have a great day um
yeah I hope you're enjoying all these live streams that we've been doing every week I like them I think they're fun and
I kind of like this one I think today went relatively smooth um so anyway take care have a wonderful rest of your week
go out and make something great and take care bye
0