|
| 1 | +# |
| 2 | +# site.preview.yml |
| 3 | +# |
| 4 | +# Launch and test preview sites for each pull request. |
| 5 | +# |
| 6 | +# Requires a runner on a persistant server. |
| 7 | +# |
| 8 | +name: Preview Site |
| 9 | +on: |
| 10 | + pull_request: |
| 11 | + |
| 12 | +# Cancel jobs if another push is received. |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.event.number }} |
| 15 | + cancel-in-progress: false |
| 16 | + |
| 17 | +jobs: |
| 18 | + |
| 19 | + # Installs DDEV, clones code, starts the site. |
| 20 | + create-site: |
| 21 | + name: Create Preview Site |
| 22 | + uses: operations-project/github-action-ddev-runner/.github/workflows/operations.site.deploy.ddev.yml@feature/reusable-workflows |
| 23 | + with: |
| 24 | + |
| 25 | + # Where to install your site. |
| 26 | + git_root: /home/runner/Sites/${{ github.repository }}/pr${{ github.event.number }} |
| 27 | + |
| 28 | + # Project name for this instance. Used to generate the domain name. |
| 29 | + ddev_project_name: yourproject.pr${{ github.event.number }} |
| 30 | + |
| 31 | + # Top-level domain. Sites are hosted as subdomains under this. |
| 32 | + ddev_project_tld: preview.yourproject.com |
| 33 | + |
| 34 | + # Tell the remote workflow what to run on. |
| 35 | + github_runs_on: self-hosted |
| 36 | + |
| 37 | + # Define the github environment name, to be displayed in the UI. |
| 38 | + github_environment_name: pr${{ github.event.number }} |
| 39 | + |
| 40 | + # Define a github environment url, a link to be shown on the pull request. |
| 41 | + github_environment_url: http://yourproject.pr${{ github.event.number }}.preview.yourproject.com |
| 42 | + |
| 43 | + # To persist a site's data, set "run_prepare_command" to false. |
| 44 | + run_prepare_command: true |
| 45 | + |
| 46 | + # Prepare the site's data. Run your sync/import/install script. |
| 47 | + prepare_command: ddev drush site:install |
| 48 | + |
| 49 | + # Command to run after deploying code changes |
| 50 | + deploy_command: ddev drush updb |
| 51 | + |
| 52 | + # Additional ddev config to apply to the environment. |
| 53 | + # Will be saved to .ddev/config.zzz.runner.yaml |
| 54 | + # See your project's .ddev/config.yaml file for examples. |
| 55 | + ddev_config: | |
| 56 | + additional_fqdns: |
| 57 | + - admin.pr${{ github.event.number }}.preview.yourproject.com |
| 58 | + |
| 59 | + run-command: |
| 60 | + name: DDEV Status |
| 61 | + uses: operations-project/github-action-ddev-runner/.github/workflows/operations.site.command.yml@feature/reusable-workflows |
| 62 | + needs: create-site |
| 63 | + with: |
| 64 | + working_directory: /home/runner/Sites/${{ github.repository }}/pr${{ github.event.number }} |
| 65 | + github_runs_on: self-hosted |
| 66 | + command: | |
| 67 | + ddev status |
| 68 | + |
| 69 | + test-site: |
| 70 | + name: Run tests |
| 71 | + needs: run-command |
| 72 | + runs-on: self-hosted |
| 73 | + steps: |
| 74 | + - uses: jonpugh/goatscripts@main |
| 75 | + - name: Check homepage |
| 76 | + env: |
| 77 | + SUCCESS: "Tests pass. :check:" |
| 78 | + ERROR: "TESTS FAILED! :x:" |
| 79 | + run: | |
| 80 | + run-with-summary curl http://pr${{ github.event.number }}.sites.thinkdrop.net |
| 81 | + curl -s http://yourproject.pr${{ github.event.number }}.preview.yourproject.com | grep "Hello World!" |
0 commit comments