forked from tc39/ecma262
-
-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (56 loc) · 1.97 KB
/
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
name: Upload Preview
on:
workflow_run:
workflows: ["Build Preview"]
types:
- completed
jobs:
upload:
name: 'upload PR preview'
runs-on: ubuntu-latest
if: >
${{
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.repository == 'tc39/ecma262'
}}
steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm ci'
with:
node-version: lts/*
use-npm-ci: true
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
const { owner, repo } = context.repo;
const artifacts = await github.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: ${{ github.event.workflow_run.id }},
});
const { id: artifact_id } = artifacts.data.artifacts.find((artifact) => artifact.name == 'out');
const download = await github.actions.downloadArtifact({
owner,
repo,
artifact_id,
archive_format: 'zip',
});
const fs = require('fs');
fs.writeFileSync('${{ github.workspace }}/out.zip', Buffer.from(download.data));
- run: unzip -o out.zip -d out
- name: 'debug info'
uses: actions/github-script@v3.1.0
with:
script: |
console.log(${{ toJson(github.event) }});
- run: head -n1 out/pr.txt | grep -e '^[1-9][0-9]*$'
name: 'validate PR number from archive'
- run: echo "PULL_REQUEST=$(head -n1 out/pr.txt)" >> $GITHUB_ENV
- run: rm out/pr.txt && echo $PULL_REQUEST
- run: node scripts/publish-preview
env:
CI_PREVIEW_TOKEN: ${{ secrets.CI_PREVIEW_TOKEN }}
GITHUB_HEAD_SHA: ${{ github.event.workflow_run.head_commit.id }}