-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test pipeline * add id to install step * wip * upload renderer and kernel * enable branch testing * fix renderer branch * prevent comment flood * normalize renderer-urn -> renderer * use new cdn * Update main.yml * npm with cache
- Loading branch information
Showing
8 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
on: | ||
pull_request: | ||
|
||
name: Pull request | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Use Node.js 14.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
cache: npm | ||
|
||
- id: install | ||
name: install | ||
run: npm ci | ||
|
||
- name: build | ||
run: npm run build | ||
- name: test | ||
run: npm run test | ||
|
||
- name: deploy preview | ||
env: | ||
AWS_DEFAULT_REGION: us-east-1 | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
EXPLORER_WEB_BUCKET: ${{ secrets.EXPLORER_WEB_BUCKET }} | ||
if: ${{ steps.install.outputs.public_path }} | ||
run: | | ||
npx @dcl/cdn-uploader@next \ | ||
--bucket $EXPLORER_WEB_BUCKET \ | ||
--local-folder build \ | ||
--bucket-folder "${{ steps.install.outputs.public_path }}" | ||
- name: Find Comment | ||
uses: peter-evans/find-comment@v1 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: "github-actions[bot]" | ||
body-includes: Test this pull request | ||
|
||
- name: Create or update comment | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
# Test this pull request | ||
This branch can be previewed at ${{ steps.install.outputs.public_url }} | ||
edit-mode: replace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,67 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const dotenv = require('dotenv') | ||
const childProcess = require('child_process') | ||
|
||
let ENV_CONTENT = {} | ||
|
||
if (fs.existsSync('.env')) { | ||
Object.assign(ENV_CONTENT, dotenv.parse(fs.readFileSync('.env'))) | ||
} | ||
|
||
const commitVersion = childProcess.execSync('git rev-parse HEAD').toString().trim() | ||
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString()) | ||
const publicPackageJson = JSON.parse(fs.readFileSync('./public/package.json').toString()) | ||
|
||
const kernelVersion = JSON.parse(fs.readFileSync(require.resolve('decentraland-kernel/package.json'))).version | ||
const rendererVersion = JSON.parse(fs.readFileSync(require.resolve('@dcl/unity-renderer/package.json'))).version | ||
|
||
ENV_CONTENT['KERNEL_PATH'] = path.dirname(require.resolve('decentraland-kernel/package.json')) | ||
ENV_CONTENT['REACT_APP_WEBSITE_VERSION'] = commitVersion | ||
ENV_CONTENT['REACT_APP_WEBSITE_VERSION'] = packageJson.version | ||
ENV_CONTENT['REACT_APP_RENDERER_VERSION'] = rendererVersion | ||
ENV_CONTENT['REACT_APP_KERNEL_VERSION'] = kernelVersion | ||
|
||
console.log('VERSIONS:', Object.entries(ENV_CONTENT), '\n') | ||
Object.assign(ENV_CONTENT, getPublicUrls()) | ||
|
||
packageJson.homepage = ENV_CONTENT['PUBLIC_URL'] | ||
|
||
// github action outputs. Do not touch. | ||
console.log('::set-output name=public_url::' + packageJson.homepage) | ||
console.log('::set-output name=public_path::' + new URL(packageJson.homepage).pathname) | ||
|
||
console.log('VERSIONS: ', Object.entries(ENV_CONTENT), '\n') | ||
|
||
fs.writeFileSync( | ||
'.env', | ||
Object.entries(ENV_CONTENT) | ||
.map((e) => e[0] + '=' + JSON.stringify(e[1])) | ||
.join('\n') + '\n' | ||
) | ||
|
||
publicPackageJson.homepage = packageJson.homepage | ||
publicPackageJson.version = packageJson.version | ||
|
||
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2)) | ||
fs.writeFileSync('./public/package.json', JSON.stringify(publicPackageJson, null, 2)) | ||
|
||
function getPublicUrls() { | ||
if (process.env.GITHUB_BASE_REF) { | ||
// Pull request | ||
return { | ||
PUBLIC_URL: `https://explorer-artifacts.decentraland.org/${packageJson.name}/branch/${process.env.GITHUB_HEAD_REF}`, | ||
REACT_APP_RENDERER_BASE_URL: ``, | ||
REACT_APP_KERNEL_BASE_URL: `` | ||
} | ||
} else if (process.env.CI) { | ||
// master/main branch, also releases | ||
return { | ||
PUBLIC_URL: `https://cdn.decentraland.org/${packageJson.name}/${packageJson.version}`, | ||
REACT_APP_RENDERER_BASE_URL: ``, | ||
REACT_APP_KERNEL_BASE_URL: `` | ||
} | ||
} | ||
// localhost | ||
return { | ||
PUBLIC_URL: `http://localhost:3000`, | ||
REACT_APP_RENDERER_BASE_URL: `/cdn/packages/unity-renderer/${rendererVersion}/`, | ||
REACT_APP_KERNEL_BASE_URL: `/cdn/packages/decentraland-kernel/${kernelVersion}/` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters