Skip to content

Commit a4a44e4

Browse files
committed
Add cache and PR preview
1 parent 1d0931a commit a4a44e4

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

.github/workflows/deploy.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ on:
66
- master
77

88
jobs:
9-
build:
9+
deploy:
1010
runs-on: ubuntu-latest
1111

1212
steps:
1313
- uses: actions/checkout@v1
14+
- uses: actions/cache@v2
15+
with:
16+
path: "**/node_modules"
17+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
1418
- name: Install dependencies
1519
run: yarn
1620
- name: Build website

.github/workflows/preview.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Preview
2+
3+
on: pull_request
4+
5+
jobs:
6+
deploy:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: actions/cache@v2
12+
with:
13+
path: "**/node_modules"
14+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
15+
- name: Install dependencies
16+
run: yarn
17+
- name: Build website
18+
run: yarn build
19+
- uses: netlify/actions/cli@master
20+
id: deploy-neflify
21+
with:
22+
args: deploy --dir=build/
23+
env:
24+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
25+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
26+
- name: Find Deploy Comment
27+
uses: peter-evans/find-comment@v1
28+
id: find_comment
29+
with:
30+
token: ${{ secrets.BOT_TOKEN }}
31+
issue-number: ${{ github.event.number }}
32+
comment-author: pythonpizzabot
33+
- name: Create comment
34+
uses: peter-evans/create-or-update-comment@v1
35+
if: ${{ steps.find_comment.outputs.comment-id == null }}
36+
with:
37+
token: ${{ secrets.BOT_TOKEN }}
38+
issue-number: ${{ github.event.number }}
39+
body: |
40+
This pull request is being automatically deployed to Netlify.
41+
42+
🔍 Inspect: ${{ steps.deploy-neflify.outputs.NETLIFY_LOGS_URL }}
43+
✅ Preview: ${{ steps.deploy-neflify.outputs.NETLIFY_URL }}
44+
- name: Update comment
45+
uses: peter-evans/create-or-update-comment@v1
46+
if: ${{ steps.find_comment.outputs.comment-id != null }}
47+
with:
48+
token: ${{ secrets.BOT_TOKEN }}
49+
issue-number: ${{ github.event.number }}
50+
edit-mode: replace
51+
comment-id: ${{ steps.find_comment.outputs.comment-id }}
52+
body: |
53+
This pull request is being automatically deployed to Netlify.
54+
55+
🔍 Inspect: ${{ steps.deploy-neflify.outputs.NETLIFY_LOGS_URL }}
56+
✅ Preview: ${{ steps.deploy-neflify.outputs.NETLIFY_URL }}

0 commit comments

Comments
 (0)