1name: Preview PR 2on: 3 pull_request_target: 4 types: [ labeled ] 5 6jobs: 7 build: 8 runs-on: "ubuntu-22.04" 9 if: "github.repository_owner == 'php' && github.event.label.name == 'Status: Preview Allowed'" 10 steps: 11 - uses: actions/checkout@v4 12 with: 13 ref: "refs/pull/${{ github.event.number }}/merge" 14 15 - uses: easingthemes/ssh-deploy@main 16 with: 17 REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }} 18 REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }} 19 SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }} 20 TARGET: "/home/thephpfoundation/preview/web-php-pr-${{ github.event.number }}/public" 21 SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php ${{ github.event.number }} 22 SCRIPT_AFTER: bash /home/thephpfoundation/scripts/pr_created.sh web-php ${{ github.event.number }} 23 24 - uses: peter-evans/find-comment@v3 25 id: fc 26 with: 27 issue-number: ${{ github.event.number }} 28 comment-author: 'github-actions[bot]' 29 body-includes: 'Preview for commit' 30 31 - uses: peter-evans/create-or-update-comment@v4 32 with: 33 issue-number: ${{ github.event.number }} 34 comment-id: ${{ steps.fc.outputs.comment-id }} 35 edit-mode: 'replace' 36 body: | 37 Preview for commit ${{ github.sha }} can be found at https://web-php-pr-${{ github.event.number }}.preview.thephp.foundation 38 39 tests_visual: 40 name: "Visual Tests" 41 42 runs-on: "ubuntu-latest" 43 if: "github.repository_owner == 'php' && github.event.label.name == 'Status: Preview Allowed'" 44 45 strategy: 46 matrix: 47 php-version: 48 - "8.2" 49 node-version: 50 - "22.x" 51 52 env: 53 HTTP_HOST: "localhost:8080" 54 55 steps: 56 - uses: actions/checkout@v4 57 with: 58 ref: "refs/pull/${{ github.event.number }}/merge" 59 60 - uses: shivammathur/setup-php@v2 61 with: 62 coverage: "none" 63 extensions: "none, curl, dom, json, mbstring, tokenizer, xml, xmlwriter" 64 php-version: "${{ matrix.php-version }}" 65 66 - name: Use Node.js ${{ matrix.node-version }} 67 uses: actions/setup-node@v4 68 with: 69 node-version: ${{ matrix.node-version }} 70 71 - name: "Set up problem matchers for PHP" 72 run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"" 73 74 - name: "Set up problem matchers for phpunit/phpunit" 75 run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"" 76 77 - name: "Determine composer cache directory" 78 run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV" 79 80 - name: "Cache dependencies installed with composer" 81 uses: actions/cache@v4 82 with: 83 path: "${{ env.COMPOSER_CACHE_DIR }}" 84 key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" 85 restore-keys: "php-${{ matrix.php-version }}-composer-" 86 87 - name: "Install dependencies with composer" 88 run: "composer install --ansi --no-interaction --no-progress" 89 90 - name: "Install dependencies" 91 run: "yarn install" 92 93 - name: "Install Playwright" 94 run: "npx playwright install" 95 96 - name: "Run visual tests" 97 run: "make tests_visual" 98 99 - uses: actions/upload-artifact@v4 100 if: ${{ !cancelled() }} 101 with: 102 name: playwright-report 103 path: playwright-report/ 104 retention-days: 30 105 106 - uses: easingthemes/ssh-deploy@main 107 if: ${{ !cancelled() }} 108 with: 109 REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }} 110 REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }} 111 SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }} 112 SOURCE: "playwright-report/" 113 TARGET: "/home/thephpfoundation/preview/web-php-regression-report-pr-${{ github.event.number }}/public" 114 SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php-regression-report ${{ github.event.number }} 115 116 - uses: peter-evans/find-comment@v3 117 if: ${{ !cancelled() }} 118 id: snapshot 119 with: 120 issue-number: ${{ github.event.number }} 121 comment-author: 'github-actions[bot]' 122 body-includes: 'Regression report for commit' 123 124 - uses: peter-evans/create-or-update-comment@v4 125 if: ${{ !cancelled() }} 126 with: 127 issue-number: ${{ github.event.number }} 128 comment-id: ${{ steps.snapshot.outputs.comment-id }} 129 edit-mode: 'replace' 130 body: | 131 Regression report for commit ${{ github.sha }} is at https://web-php-regression-report-pr-${{ github.event.number }}.preview.thephp.foundation 132