-
Notifications
You must be signed in to change notification settings - Fork 189
51 lines (44 loc) · 1.88 KB
/
preview-url-comment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# GitHub Action that creates a comment displaying the lit.dev preview URL for
# each PR, and updates the comment on each push.
name: Preview URL Comment
on:
pull_request:
types: [opened, synchronize]
jobs:
preview-url-comment:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Generate preview URL
id: gen-url
run: echo "::set-output name=url::https://pr${{ github.event.number }}-$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-7)---lit-dev-5ftespv5na-uc.a.run.app/"
# https://github.com/peter-evans/find-comment
- name: Find existing comment
uses: peter-evans/find-comment@v1
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: preview of this PR will be available
# https://github.com/peter-evans/create-or-update-comment
- name: Create comment (if new)
if: ${{ steps.find-comment.outputs.comment-id == 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
edit-mode: replace
body: |
A live preview of this PR will be available at the URL(s) below.
The latest URL will be appended to this comment on each push.
Each build takes ~5-10 minutes, and will 404 until finished.
${{ steps.gen-url.outputs.url }}
reactions: eyes
- name: Update comment (if existing)
if: ${{ steps.find-comment.outputs.comment-id != 0 }}
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: append
body: ${{ steps.gen-url.outputs.url }}