Skip to content

Commit

Permalink
Add Preview action
Browse files Browse the repository at this point in the history
  • Loading branch information
saundefined committed Dec 11, 2023
1 parent ede0692 commit 134e200
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pr-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Remove preview PR
on:
pull_request:
types: [ closed ]

jobs:
build:
runs-on: "ubuntu-22.04"
if: github.repository_owner == 'php'
steps:
- uses: appleboy/[email protected]
with:
host: ${{ secrets.PREVIEW_REMOTE_HOST }}
username: ${{ secrets.PREVIEW_REMOTE_USER }}
key: ${{ secrets.PREVIEW_SSH_KEY }}
script: bash /home/thephpfoundation/scripts/pr_closed.sh web-php ${{ github.event.number }}
28 changes: 28 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Preview PR
on:
pull_request_target:

jobs:
build:
runs-on: "ubuntu-22.04"
if: github.repository_owner == 'php'
steps:
- uses: actions/checkout@v4
with:
ref: "refs/pull/${{ github.event.number }}/merge"

- uses: easingthemes/ssh-deploy@main
with:
REMOTE_HOST: ${{ secrets.PREVIEW_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.PREVIEW_REMOTE_USER }}
SSH_PRIVATE_KEY: ${{ secrets.PREVIEW_SSH_KEY }}
TARGET: "/home/thephpfoundation/preview/web-php-pr-${{ github.event.number }}/public"
SCRIPT_BEFORE: bash /home/thephpfoundation/scripts/pr_created_pre.sh web-php ${{ github.event.number }}
SCRIPT_AFTER: bash /home/thephpfoundation/scripts/pr_created.sh web-php ${{ github.event.number }}

- uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.number }}
edit-mode: 'replace'
body: |
🚀 Deployed on https://web-php-pr-${{ github.event.number }}.preview.thephp.foundation

0 comments on commit 134e200

Please sign in to comment.