Skip to content

Upload Preview

Upload Preview #54

Workflow file for this run

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@v3
- uses: ljharb/actions/node/install@d9f477827ed71a259056764107f74afc29febcae
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 }}