Chapters

Deployments

How to Setup True Market Deployments

We use Bitbucket Pipelines here to handle deployments. Follow the steps below to learn how to setup and run pipelines.

  1. In your Bitbucket account, navigate to the repository you are working on
  2. Click Repository Settings > Settings > Enable Pipelines
  3. Go to Repository settings > SSH Keys > Use my own keys
  4. Add your private and public keys in their respective fields
    1. Those should be located in your Users/User/.ssh folder on your machine
    2. If not, see section 1 of this document to learn how to create an SSH key
  5. Click Save key pair
  6. Paste 67.205.191.75 (the staging server’s IP address) or the server’s IP you want to deploy to in the Known hosts field and click Fetch, then Add host
  7. Go to Pipelines and select Starter Pipeline
  8. Paste this code in the bitbucket-pipelines.yml editor and click Click Commit file:

Note

If you do not see the Starter Pipeline button, it means a bitbucket.yaml file already exsits. So just click Run initial pipeline and check the configuration. Make sure it looks similar to the code below (swap DOMAIN for the staging site’s actual domain) then select the master branch and the custom: deploy-to-staging pipeline and Run it.

Markdown
        
            definitions:
  steps:
  - step: &staging_deploy
      name: Deploy to Staging
      script:
      - pipe: atlassian/rsync-deploy:0.13.0
        variables:
          USER: forge
          SERVER: 67.205.191.75
          REMOTE_PATH: "/home/forge/DOMAIN/public/wp-content/themes/truemarket"
          LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/'
pipelines:
  custom:
    deploy-to-staging:
    - step: *staging_deploy        
    

Deploying to Production

When ready to deploy to production, add this code below the existing deploy to staging YAML code. Please note that you will need to fetch the production server’s host (repeat step 6 above) and replace LIVE SERVER IP and DOMAIN with the correct information.

Markdown
        
            # Pipeline for production deployment
    deploy-to-production:
    - variables:
        - name: CONFIRM_DEPLOY
          default: "no"
          allowed-values:
            - "yes"
            - "no"
    - step:
        name: "Confirm Deployment"
        script:
          - |
            if [ "$CONFIRM_DEPLOY" != "yes" ]; then
              echo "❌ Deployment cancelled"
              exit 1
            fi
    - step:
        name: Deploy to Production
        script:
          - echo "⚠️ Deploying to production ⚠️"
          - pipe: atlassian/rsync-deploy:0.13.0
            variables:
              USER: forge
              SERVER: LIVE SERVER IP
              REMOTE_PATH: '/home/forge/DOMAIN/wordpress/wp-content/themes/truemarket'
              LOCAL_PATH: '${BITBUCKET_CLONE_DIR}/'
        
    

How to Deploy Changes

  1. Go to the project’s repository and go to Pipelines. If this is the first deployment, click Run initial pipeline, otherwise, click Run Pipeline
  2. Select the master branch and custom: deploy-to-staging or custom: deploy-to-production if pushing to a production server
  3. Click Run
  4. Once the pipeline is done running, your changes should have deployed on the site
  5. Make sure to go to ACF and check if the sync button is available. If so, sync all changes. This will make sure that the acf-json changes are synced with the database.

How to Manually deploy changes via SFTP

If for whatever reason you are unable to run a pipeline or need to push some code to a site that doesn’t have a repo, follow the steps below. It’s a good idea to backup the remote site’s theme files before overwriting with your local ones.

  1. Follow the steps here to generate and add your SSH key to Forge (if this has not already been done) and to learn how to connect to a Forge server via SFTP.
    1. Note: If pushing code to a site we do not host, you will need to get the client’s SFTP information (host, user and password)
  2. Once connected, navigate to the truemarket theme folder.
  3. On your local machine, navigate to the project theme folder
  4. Select every file/folder, except node_modules, .git, and .gitignore
  5. You can do this with the ctrl+a shortcut then holding ctrl+clicking on the individual files/folders
  6. Right-click the local files you selected and click on upload:
    1. Note: If you only made CSS/JS changes, you could also just upload your assets folder instead of the entire theme every time. Though you should always include the functions.php file to handle cache busting.
  7. Select Overwrite and check Apply to current queue only when prompted
  8. Open the remote site and make sure your changes came through without breaking anything.