Skip to content

Commit 5006cc0

Browse files
authored
Add Preview action (#893)
1 parent 9482f9b commit 5006cc0

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.github/workflows/pr-closed.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Remove preview PR
2+
on:
3+
pull_request:
4+
types: [ closed ]
5+
6+
jobs:
7+
build:
8+
runs-on: "ubuntu-22.04"
9+
if: github.repository_owner == 'php'
10+
steps:
11+
- uses: appleboy/[email protected]
12+
with:
13+
host: ${{ secrets.PREVIEW_REMOTE_HOST }}
14+
username: ${{ secrets.PREVIEW_REMOTE_USER }}
15+
key: ${{ secrets.PREVIEW_SSH_KEY }}
16+
script: bash /home/thephpfoundation/scripts/pr_closed.sh web-php ${{ github.event.number }}

.github/workflows/pr-preview.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Preview PR
2+
on:
3+
pull_request_target:
4+
5+
jobs:
6+
build:
7+
runs-on: "ubuntu-22.04"
8+
if: github.repository_owner == 'php'
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
ref: "refs/pull/${{ github.event.number }}/merge"
13+
14+
- uses: easingthemes/ssh-deploy@main
15+
with:
16+
REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }}
17+
REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }}
18+
SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }}
19+
TARGET: "/home/thephpfoundation/preview/web-php-pr-${{ github.event.number }}/public"
20+
SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php ${{ github.event.number }}
21+
SCRIPT_AFTER: bash /home/thephpfoundation/scripts/pr_created.sh web-php ${{ github.event.number }}
22+
23+
- uses: peter-evans/create-or-update-comment@v3
24+
with:
25+
issue-number: ${{ github.event.number }}
26+
edit-mode: 'replace'
27+
body: |
28+
🚀 Deployed on https://web-php-pr-${{ github.event.number }}.preview.thephp.foundation

0 commit comments

Comments
 (0)