@@ -3,61 +3,83 @@ name: Upload to staging
33on : issue_comment
44
55jobs :
6- upload-to-staging :
7- if : github.event.action == 'created'
6+ build :
87 runs-on : ubuntu-latest
98 steps :
10- - uses : actions/checkout@v2
9+ - uses : actions/github-script@0.3.0
10+ if : github.event.action == 'created'
11+ with :
12+ github-token : ${{ secrets.GITHUB_TOKEN }}
13+ script : |
14+ const isValidPreview = (
15+ context.payload.action === 'created' &&
16+ context.payload.issue.pull_request &&
17+ context.payload.comment.body === '/preview'
18+ );
19+ if (!isValidPreview) return;
20+ github.issues.createComment({
21+ issue_number: context.issue.number,
22+ owner: context.repo.owner,
23+ repo: context.repo.repo,
24+ body: 'Please find a preview at: https://staging.nodejs.dev/${{ steps.vars.outputs.pr_number }}/'
25+ });
1126
12- - uses : actions/github-script@0.3.0
13- whith :
14- github-token : ${{ secrets.GITHUB_TOKEN }}
15- script : |
16- const isValidPR = (
17- context.payload.action === 'created' &&
18- context.payload.issue.pull_request &&
19- context.payload.comment.body === '/preview'
20- )
21-
22- - name : Get PR Number
23- id : vars
24- run : echo "::set-output name=pr_number::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"
25-
26- - name : Setup GCloud
27- uses : GoogleCloudPlatform/github-actions/setup-gcloud@master
28- with :
29- project_id : ${{ secrets.GCP_PROJECT_ID }}
30- service_account_email : ${{ secrets.GCP_SA_EMAIL }}
31- service_account_key : ${{ secrets.GCP_SA_KEY }}
32- export_default_credentials : true
33-
34- - uses : actions/cache@v1
35- with :
36- path : ~/.npm
37- key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
38- restore-keys : |
39- ${{ runner.os }}-node-
40-
41- - name : Install Dependencies
42- if : steps.cache.outputs.cache-hit != 'true'
43- run : npm ci
44-
45- - name : Run Gatsby Build
46- run : npm run build-ci
47- env :
48- PATH_PREFIX : ${{ steps.vars.outputs.pr_number }}/
49-
50- - name : Upload to GCS
51- run : gsutil -m rsync -R ./public/ gs://staging.nodejs.dev/${{ steps.vars.outputs.pr_number }}/
52-
53- - name : Comment on PR
54- uses : actions/github-script@0.9.0
55- with :
56- github-token : ${{secrets.GITHUB_TOKEN}}
57- script : |
58- github.issues.createComment({
59- issue_number: context.issue.number,
60- owner: context.repo.owner,
61- repo: context.repo.repo,
62- body: 'Please find a preview at: https://staging.nodejs.dev/${{ steps.vars.outputs.pr_number }}/'
63- });
27+ # jobs:
28+ # upload-to-staging:
29+ # if: github.event.action == 'created'
30+ # runs-on: ubuntu-latest
31+ # steps:
32+ # - uses: actions/checkout@v2
33+ #
34+ # - uses: actions/github-script@0.3.0
35+ # whith:
36+ # github-token: ${{ secrets.GITHUB_TOKEN }}
37+ # script: |
38+ # const isValidPR = (
39+ # context.payload.action === 'created' &&
40+ # context.payload.issue.pull_request &&
41+ # context.payload.comment.body === '/preview'
42+ # )
43+ #
44+ # - name: Get PR Number
45+ # id: vars
46+ # run: echo "::set-output name=pr_number::$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"
47+ #
48+ # - name: Setup GCloud
49+ # uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
50+ # with:
51+ # project_id: ${{ secrets.GCP_PROJECT_ID }}
52+ # service_account_email: ${{ secrets.GCP_SA_EMAIL }}
53+ # service_account_key: ${{ secrets.GCP_SA_KEY }}
54+ # export_default_credentials: true
55+ #
56+ # - uses: actions/cache@v1
57+ # with:
58+ # path: ~/.npm
59+ # key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
60+ # restore-keys: |
61+ # ${{ runner.os }}-node-
62+ #
63+ # - name: Install Dependencies
64+ # if: steps.cache.outputs.cache-hit != 'true'
65+ # run: npm ci
66+ #
67+ # - name: Run Gatsby Build
68+ # run: npm run build-ci
69+ # env:
70+ # PATH_PREFIX: ${{ steps.vars.outputs.pr_number }}/
71+ #
72+ # - name: Upload to GCS
73+ # run: gsutil -m rsync -R ./public/ gs://staging.nodejs.dev/${{ steps.vars.outputs.pr_number }}/
74+ #
75+ # - name: Comment on PR
76+ # uses: actions/github-script@0.9.0
77+ # with:
78+ # github-token: ${{secrets.GITHUB_TOKEN}}
79+ # script: |
80+ # github.issues.createComment({
81+ # issue_number: context.issue.number,
82+ # owner: context.repo.owner,
83+ # repo: context.repo.repo,
84+ # body: 'Please find a preview at: https://staging.nodejs.dev/${{ steps.vars.outputs.pr_number }}/'
85+ # });
0 commit comments