This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
76 lines (64 loc) · 2.22 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
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Generate Preview
on:
pull_request_target:
types: [labeled]
permissions:
contents: read
pull-requests: write
jobs:
generate-preview:
environment:
name: firebase-staging
url: 'https://staging.nodejs.dev/${{ github.event.pull_request.number }}/'
runs-on: ubuntu-latest
if: github.event.label.name == 'create-preview'
steps:
- name: Git Checkout
uses: actions/checkout@v3.3.0
with:
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Auth G Cloud
uses: 'google-github-actions/auth@v1'
with:
credentials_json: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NODEJS_INFRASTRUCTURE }}'
- name: Setup G Cloud
uses: google-github-actions/setup-gcloud@v1
- name: Remove the PR Label
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.removeLabel({
issue_number: ${{ github.event.pull_request.number }},
owner: context.repo.owner,
repo: context.repo.repo,
name: ['create-preview']
})
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install NPM packages
run: npm ci
- uses: jongwooo/gatsby-cache@v1.4.1
with:
key: generate-preview-gatsby-ubuntu-latest
- name: Build Gatsby
run: npm run build-ci
env:
PATH_PREFIX: ${{ github.event.pull_request.number }}/
- name: Upload to G Cloud Storage
run: gsutil -m rsync -R public gs://staging.nodejs.dev/${{ github.event.pull_request.number }}/
- name: Comment on PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.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 }}/'
});