Skip to content

Commit 55df7d7

Browse files
committed
Add unmerged PR example
1 parent 1c3ee7e commit 55df7d7

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,37 @@ jobs:
164164
action: auto
165165
```
166166

167-
### Reimplementing `auto`
167+
### Only remove previews for unmerged PRs
168168

169-
If you don't trust my implementation of `auto`, you can do it yourself
169+
Information from the context and conditionals can be used to make more
170+
complex decisions about what to do with previews; for example, removing
171+
only those associated with _unmerged_ PRs when they are closed:
172+
173+
```yml
174+
# .github/workflows/preview.yml
175+
name: Deploy PR previews; removed closed unmerged PR previews
176+
on:
177+
pull_request:
178+
types:
179+
- synchronize
180+
- closed
181+
jobs:
182+
deploy-preview:
183+
runs-on: ubuntu-20.04
184+
steps:
185+
- uses: actions/checkout@v2
186+
- run: npm i && npm run build
187+
- uses: rossjrw/pr-preview-action@v1
188+
if: github.event.action == "synchronize"
189+
with:
190+
source-dir: ./build/
191+
action: deploy
192+
- uses: rossjrw/pr-preview-action@v1
193+
if: github.event.action == "closed" && !github.event.pull_request.merged
194+
with:
195+
source-dir: ./build/
196+
action: remove
197+
```
170198

171199
### Permanent previews
172200

0 commit comments

Comments
 (0)