Github Process

How to setup a new Repo on github.com for SQRD Media

Prerequisites: - Need a Github account with access to SQRD Media's organization.

Steps to setting up a client Repo:

  1. Click the "+" icon in the top right corner and select "New repository".
  2. Make sure to select "SQRD Media" as the account owner.
  3. Name the Repo as close to the project url as you can example: "sqrdmedia.com"
  4. Enter a name for your repository and select "Private" under "Visibility".
  5. Add a read me file
  6. Prese Create Repository

At this point you now have a repo that can be pulled to your local dev environment.

Initial Commit ( Wordpress ): *Best to setup the repo with these steps before installing Wordpress*

  1. Setup a .gitignore file in the root of the repo and use the WP-Engine WP template found here.
  2. Add "node_modules" to the .gitignore file
  3. Push that to the repo
  4. You can now install WordPress using whatever method you find best for your localhost.
.

Auto Deploys to FTP:

  1. Create in the repo a file that is the same name as the main/master branch name in the folders "/.github/workflows/[mainbranchname].yml" without the brackets.
  2. Add the following to the file:
    jsx
    name: Deploy to data.evcars.com
    on:
     push:
      branches:
      - master
    jobs:
     build:
      runs-on: ubuntu-latest
      steps:
      - uses: actions/checkout@v1
      - name: Install Node.js
       uses: actions/setup-node@v1
       with:
        node-version: '10.x'
      - name: Deploy to Server
       uses: easingthemes/ssh-deploy@main
       env:
        SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
        ARGS: "-rltgoDzvO"
        SOURCE: ""
        REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
        REMOTE_USER: ${{ secrets.REMOTE_USER }}
        TARGET: ${{ secrets.REMOTE_TARGET }}
        EXCLUDE: "/dist/, /.git/, /.github/, /README.md, /node_modules/"
    
  3. Change the name of the branch to the name of the branch you want it to listen for above.
  4. Inside Github go into the repo that you would like to create this deploy with.
  5. This method uses SSH and you’ll need a copy of your SSH Private key to access the server.
  6. In the Repo click settings
    1. click Secrets and variables
      1. Click actions
        1. Create a new repository secret for REMOTE_USER most cases this is "root"
        2. Create a new repository secret for REMOTE_TARGET with the file path to the site, in most cases it’s "/var/www/site.com/htdocs/"
        3. Create a new repository secret for REMOTE_HOST with the ip address of the server.
        4. Create a new repository secret for SSH_PRIVATE_KEY and copy your ssh key that is used to access the server with in there.
  7. Once step 5 is finished you should be able to push and then go to the actions tab in Github and watch Github deploy the code.
  8. If you run into an error google "easingthemes/ssh-deploy@main" and look at their docs.
  9. Other branches will need their own file, example: "develop.yml" with the branch name changed to develop.

Auto Deploys to WP-Engine:

  1. Create in the repo a file that is the same name as the main/master branch name in the folders "/.github/workflows/[mainbranchname].yml" without the brackets.
  2. Add the following to the file:
    				
    jsx
    name: Deploy to WP Engine
    on:
     push:
      branches:
       - main
    jobs:
     build:
      runs-on: ubuntu-latest
      steps:
       - uses: actions/checkout@v2
       - name: GitHub Action Deploy to WP Engine
       uses: wpengine/github-action-wpe-site-deploy@v3.0
       with:
       WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
       WPE_ENV: evcarscom
    
  3. Change the name of the branch to the name of the branch you want it to listen for above.
  4. Change the WPE_ENV var to the name WP-engine gives you.
  5. Inside Github go into the repo that you would like to create this deploy with.
  6. This method uses SSH and you’ll need a copy of your SSH Private key to access the server.
  7. In the Repo click settings
    1. click Secrets and variables
      1. Click actions
        1. Create a new repository secret for WPE_SSH_PRIVATE_KEY and copy your ssh key that is used to access your account in WP-Engine.
  8. Once step 5 is finished you should be able to push and then go to the actions tab in Github and watch Github deploy the code.
  9. If you run into an error google "wpengine/github-action-wpe-site-deploy@v3.0" and look at their docs.
  10. Other branches will need their own file, example: "develop.yml" with the branch name changed to develop.