Skip to content

Commit

Permalink
[meta] migrate from travis-ci to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 16, 2021
1 parent 61cc329 commit 27857dc
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 37 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'ecma-262'

on: [pull_request, push]

jobs:
build:
name: 'build & lint ecmarkup'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm install'
with:
node-version: lts/*
use-npm-ci: true
- run: 'npm ci && npm run build-master'
21 changes: 21 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'ecma-262'

on:
push:
branches:
- master

jobs:
deploy:
name: 'deploy github pages'
runs-on: ubuntu-latest
if: ${{ github.repository == 'tc39/ecma262' }}

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm install'
with:
node-version: lts/*
use-npm-ci: true
- run: npm ci && npm run build-only ./scripts/auto-deploy.sh
24 changes: 24 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: 'ecma-262'

on: [pull_request_target]

jobs:
upload:
name: 'upload PR preview'
runs-on: ubuntu-latest
if: ${{ github.repository == 'tc39/ecma262' }}

steps:
- uses: actions/checkout@v2
- uses: ljharb/actions/node/install@56f291b2a0d9e3bce72634356ae949b1e054b9f8
name: 'nvm install lts/* && npm install'
with:
node-version: lts/*
use-npm-ci: true
- run: npm run build-only
- run: node scripts/insert_snapshot_warning
- run: node scripts/publish-preview
env:
CI_PREVIEW_TOKEN: ${{ secrets.CI_PREVIEW_TOKEN }}
PULL_REQUEST: ${{ github.event.number }}

31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

15 changes: 9 additions & 6 deletions scripts/publish-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,27 @@ const tar = require('tar-stream');


async function go() {
const { TRAVIS_PULL_REQUEST, TRAVIS_PULL_REQUEST_SHA } = process.env;
const {
PULL_REQUEST,
GITHUB_SHA,
} = process.env;

if (!TRAVIS_PULL_REQUEST) { throw new ReferenceError('Missing env var TRAVIS_PULL_REQUEST'); }
if (!TRAVIS_PULL_REQUEST_SHA) { throw new ReferenceError('Missing env var TRAVIS_PULL_REQUEST_SHA'); }
if (!PULL_REQUEST) { throw new ReferenceError('Missing env var PULL_REQUEST'); }
if (!GITHUB_SHA) { throw new ReferenceError('Missing env var GITHUB_SHA'); }

const dir = join(__dirname, '..', 'out');
const files = glob(join(dir, '**'), { nodir: true });

if (!files.length) { throw new ReferenceError('No preview files found to publish'); }

console.log(`Publishing preview build of PR ${TRAVIS_PULL_REQUEST} (SHA ${TRAVIS_PULL_REQUEST_SHA})`);
console.log(`Publishing preview build of PR ${PULL_REQUEST} (SHA ${GITHUB_SHA})`);

const compressed = await compress(files, dir);
console.log(`Packed to ${compressed.length / 1000}kB`);

const data = {
pr: TRAVIS_PULL_REQUEST,
sha: TRAVIS_PULL_REQUEST_SHA,
pr: PULL_REQUEST,
sha: GITHUB_SHA,
compressed,
};

Expand Down

0 comments on commit 27857dc

Please sign in to comment.