forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 1.92 KB
/
generate-preview.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
52
53
54
55
56
57
58
59
60
61
62
63
name: Generate Preview
on:
pull_request_target:
types: [labeled]
jobs:
build:
runs-on: ubuntu-latest
if: github.event.label.name == 'create-preview'
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup GCloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_email: ${{ secrets.GCP_SA_EMAIL }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Remove create-preview label
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.removeLabel({
issue_number: ${{ github.event.pull_request.number }},
owner: context.repo.owner,
repo: context.repo.repo,
name: ['create-preview']
})
- name: Install Dependencies
run: npm ci
- name: Run Gatsby Build
run: npm run build-ci
env:
PATH_PREFIX: ${{ github.event.pull_request.number }}/
- name: Run Storybook Build
run: npm run build-storybook
env:
PATH_PREFIX: ${{ github.event.pull_request.number }}/
- name: Upload to GCS
run: gsutil -m rsync -R public gs://staging.nodejs.dev/${{ github.event.pull_request.number }}/
- name: Comment on PR
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: ${{ github.event.pull_request.number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please find a preview at: https://staging.nodejs.dev/${{ github.event.pull_request.number }}/'
});