Platformsh GitHub Action

Platformsh is a hosting platform that is very flexible in spinning up environments from git branches and pull requests.

Diffy can be integrated so that it visually compares each pull request with whatever environment you like. In our example, we compare it with production. You can watch a video overview in the bottom of the page.

Complete steps to set up the integration are:

  • Set up Platformsh Github integration

  • Create a project in Diffy, specify the production environment

  • Under Project settings > Notifications > Github add URL of your GitHub repo and enable the Diffy GitHub app

  • Populate DIFFY_API_KEY and DIFFY_PROJECT_ID as secrets in the GitHub repo

  • Create a GitHub action with the following code

name: "DiffyPullRequestTest"
run-name: "DiffyPullRequestTest"
on:
  pull_request:
    branches:
      - main

jobs:
  trigger-diffy-job:
    runs-on: ubuntu-latest
    steps:
      - name: 'Wait for psh and get target url'
        id: get-target-url
        uses: platformsh/gha-retrieve-psh-prenv-url@main
        with:
            github-token: ${{ secrets.GITHUB_TOKEN }}

      - name: 'Install and Run Diffy'
        id: install-diffy-cli
        shell: bash
        env:
          diffy_api_key: '${{ secrets.DIFFY_API_KEY }}'
          diffy_project_id: '${{ secrets.DIFFY_PROJECT_ID }}'
        run: |
          wget -O /usr/local/bin/diffy https://github.com/diffywebsite/diffy-cli/releases/latest/download/diffy.phar
          chmod a+x /usr/local/bin/diffy
          diffy auth:login $diffy_api_key
          diffy project:compare $diffy_project_id prod custom --env2Url="${{ steps.get-target-url.outputs.target_url }}" --commit-sha="${{ github.event.pull_request.head.sha }}"

Once all this is done and GitHub action is merged, you create a pull request with visual changes and see how Diffy gets triggered and posts results back to the pull request.

Diffy GitHub check

Last updated