|
| 1 | +name: Preview Deploy |
| 2 | +on: |
| 3 | + workflow_run: |
| 4 | + workflows: ["Preview Tests"] |
| 5 | + types: |
| 6 | + - completed |
| 7 | + |
| 8 | +jobs: |
| 9 | + deploy: |
| 10 | + runs-on: "ubuntu-22.04" |
| 11 | + if: > |
| 12 | + github.repository_owner == 'php' && |
| 13 | + github.event.workflow_run.event == 'pull_request' && |
| 14 | + github.event.workflow_run.conclusion == 'success' |
| 15 | +
|
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v6 |
| 18 | + with: |
| 19 | + ref: ${{ github.event.workflow_run.head_branch }} |
| 20 | + |
| 21 | + - name: Download PR number |
| 22 | + uses: actions/download-artifact@v8 |
| 23 | + with: |
| 24 | + name: pr-number.txt |
| 25 | + path: ./pr-number-artifact/ |
| 26 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + run-id: ${{ github.event.workflow_run.id }} |
| 28 | + |
| 29 | + - name: Set PR number |
| 30 | + id: pr-number |
| 31 | + run: | |
| 32 | + PR_NUMBER=$(cat ./pr-number-artifact/pr-number.txt) |
| 33 | + echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT |
| 34 | +
|
| 35 | + - name: Download PR code as artifact |
| 36 | + uses: actions/download-artifact@v8 |
| 37 | + with: |
| 38 | + name: pr-code |
| 39 | + path: ./ |
| 40 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + run-id: ${{ github.event.workflow_run.id }} |
| 42 | + |
| 43 | + - name: Deploy preview |
| 44 | + uses: easingthemes/ssh-deploy@main |
| 45 | + with: |
| 46 | + REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }} |
| 47 | + REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }} |
| 48 | + SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }} |
| 49 | + SOURCE: "./" |
| 50 | + TARGET: "/home/thephpfoundation/preview/web-php-pr-${{ steps.pr-number.outputs.pr_number }}/public" |
| 51 | + SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php ${{ steps.pr-number.outputs.pr_number }} |
| 52 | + SCRIPT_AFTER: bash /home/thephpfoundation/scripts/pr_created.sh web-php ${{ steps.pr-number.outputs.pr_number }} |
| 53 | + |
| 54 | + - name: Find existing preview comment |
| 55 | + uses: peter-evans/find-comment@v4 |
| 56 | + id: fc |
| 57 | + with: |
| 58 | + issue-number: ${{ steps.pr-number.outputs.pr_number }} |
| 59 | + comment-author: 'github-actions[bot]' |
| 60 | + body-includes: 'Preview for commit' |
| 61 | + |
| 62 | + - name: Create or update preview comment |
| 63 | + uses: peter-evans/create-or-update-comment@v5 |
| 64 | + with: |
| 65 | + issue-number: ${{ steps.pr-number.outputs.pr_number }} |
| 66 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 67 | + edit-mode: 'replace' |
| 68 | + body: | |
| 69 | + 🚀 Preview for commit ${{ github.event.workflow_run.head_sha }} is available at https://web-php-pr-${{ steps.pr-number.outputs.pr_number }}.preview.thephp.foundation |
| 70 | +
|
| 71 | + deploy-regression-report: |
| 72 | + runs-on: "ubuntu-22.04" |
| 73 | + if: > |
| 74 | + github.repository_owner == 'php' && |
| 75 | + github.event.workflow_run.event == 'pull_request' && |
| 76 | + github.event.workflow_run.conclusion == 'success' |
| 77 | +
|
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v6 |
| 80 | + with: |
| 81 | + ref: ${{ github.event.workflow_run.head_branch }} |
| 82 | + |
| 83 | + - name: Download PR number |
| 84 | + uses: actions/download-artifact@v8 |
| 85 | + with: |
| 86 | + name: pr-number.txt |
| 87 | + path: ./pr-number-artifact/ |
| 88 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + run-id: ${{ github.event.workflow_run.id }} |
| 90 | + |
| 91 | + - name: Set PR number |
| 92 | + id: pr-number |
| 93 | + run: | |
| 94 | + PR_NUMBER=$(cat ./pr-number-artifact/pr-number.txt) |
| 95 | + echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT |
| 96 | +
|
| 97 | + - name: Download regression report |
| 98 | + uses: actions/download-artifact@v8 |
| 99 | + with: |
| 100 | + name: playwright-report |
| 101 | + path: ./playwright-report/ |
| 102 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + run-id: ${{ github.event.workflow_run.id }} |
| 104 | + |
| 105 | + - name: Deploy regression report |
| 106 | + uses: easingthemes/ssh-deploy@main |
| 107 | + with: |
| 108 | + REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }} |
| 109 | + REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }} |
| 110 | + SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }} |
| 111 | + SOURCE: "./playwright-report/" |
| 112 | + TARGET: "/home/thephpfoundation/preview/web-php-regression-report-pr-${{ steps.pr-number.outputs.pr_number }}/public" |
| 113 | + SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php-regression-report ${{ steps.pr-number.outputs.pr_number }} |
| 114 | + |
| 115 | + - name: Find regression report comment |
| 116 | + uses: peter-evans/find-comment@v4 |
| 117 | + id: snapshot |
| 118 | + with: |
| 119 | + issue-number: ${{ steps.pr-number.outputs.pr_number }} |
| 120 | + comment-author: 'github-actions[bot]' |
| 121 | + body-includes: 'Regression report for commit' |
| 122 | + |
| 123 | + - name: Create or update regression report comment |
| 124 | + uses: peter-evans/create-or-update-comment@v5 |
| 125 | + with: |
| 126 | + issue-number: ${{ steps.pr-number.outputs.pr_number }} |
| 127 | + comment-id: ${{ steps.snapshot.outputs.comment-id }} |
| 128 | + edit-mode: 'replace' |
| 129 | + body: | |
| 130 | + 📊 Regression report for commit ${{ github.event.workflow_run.head_sha }} is at https://web-php-regression-report-pr-${{ steps.pr-number.outputs.pr_number }}.preview.thephp.foundation |
0 commit comments