This repository was archived by the owner on Oct 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
63 lines (55 loc) · 1.68 KB
/
preview.yml
File metadata and controls
63 lines (55 loc) · 1.68 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
on:
workflow_call:
secrets:
NETLIFY_SITE_ID:
required: true
NETLIFY_AUTH_TOKEN:
required: true
jobs:
preview:
runs-on: ubuntu-latest
permissions:
contents: read
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
steps:
- name: Checkout docs repo
uses: actions/checkout@v2
with:
repository: apollographql/docs
- name: Checkout content repo
uses: actions/checkout@v2
with:
path: content
- uses: actions/setup-node@v2
with:
node-version: 14
cache: npm
- name: Install dependencies
run: npm install
- name: Build
run: npx netlify build --context=deploy-preview
env:
DOCS_PATH: content/docs/source
- name: Publish
id: publish
env:
# Passing this through an env var allows for proper escaping.
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
deploy_output=$( npx netlify deploy --json --message "${PR_TITLE}" )
deploy_url=$( echo $deploy_output | jq '.deploy_url' )
echo "::set-output name=deploy_url::$deploy_url"
- name: Set preview status
uses: actions/github-script@v5
with:
script: |
github.rest.repos.createCommitStatus({
...context.repo,
sha: context.payload.after,
state: "success",
target_url: ${{ steps.publish.outputs.deploy_url }},
description: "Deploy Preview ready!",
context: "Deploy Preview"
})