From 51ad29d74da3b548337bce2b956c3e5f4dcad2e3 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Wed, 19 Feb 2020 01:46:08 +0100 Subject: [PATCH] CI: update Github actions, move now deployment to action (#1316) --- .github/workflows/{main.yml => ci.yml} | 10 ++++----- .github/workflows/mainnet.yml | 30 ++++++++++++++++++++++++++ now-mainnet.json | 5 ++++- now.json | 7 ++++++ package.json | 2 +- scripts/build | 6 +++++- 6 files changed, 52 insertions(+), 8 deletions(-) rename .github/workflows/{main.yml => ci.yml} (67%) create mode 100644 .github/workflows/mainnet.yml diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 67% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index 8f8ad62f5..0040a59cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -8,12 +8,12 @@ jobs: - name: Install node uses: actions/setup-node@v1 with: - node-version: 10 + node-version: 12 - name: npm install run: npm install - - name: npm lint and build - run: | - npm run lint - npm run build + - name: npm build + run: npm run build + - name: npm test + run: npm run test env: CI: true diff --git a/.github/workflows/mainnet.yml b/.github/workflows/mainnet.yml new file mode 100644 index 000000000..6ea96833d --- /dev/null +++ b/.github/workflows/mainnet.yml @@ -0,0 +1,30 @@ +name: Mainnet deployment + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Install node + uses: actions/setup-node@v1 + with: + node-version: 12 + - name: npm install + run: npm install + - name: npm test + run: npm run test + - name: now + run: > + now + -A now-mainnet.json + --confirm + --prod + --token=${{ secrets.ZEIT_TOKEN }} + --build-env NOW_GITHUB_COMMIT_SHA="$(git log --pretty=format:'%h' -n 1)" + env: + CI: true diff --git a/now-mainnet.json b/now-mainnet.json index a2611ab4f..367cf8e3a 100644 --- a/now-mainnet.json +++ b/now-mainnet.json @@ -5,7 +5,10 @@ "alias": "nightly.aragon.org", "build": { "env": { - "ARAGON_ETH_NETWORK_TYPE": "main" + "ARAGON_ETH_NETWORK_TYPE": "main", + "ARAGON_FORTMATIC_API_KEY": "@aragon-client-fortmatic-api-key", + "ARAGON_PORTIS_DAPP_ID": "@aragon-client-portis-dapp-id", + "ARAGON_SENTRY_DSN": "@aragon-client-sentry-dsn" } } } diff --git a/now.json b/now.json index 4f61eaa6e..4f5650ab2 100644 --- a/now.json +++ b/now.json @@ -5,5 +5,12 @@ "alias": "nightly-rinkeby.aragon.org", "github": { "silent": true + }, + "build": { + "env": { + "ARAGON_FORTMATIC_API_KEY": "@aragon-client-fortmatic-testnet-api-key", + "ARAGON_PORTIS_DAPP_ID": "@aragon-client-portis-dapp-id", + "ARAGON_SENTRY_DSN": "@aragon-client-sentry-dsn" + } } } diff --git a/package.json b/package.json index 0477a4d0f..c38d1b436 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "build:staging": "cross-env ARAGON_ENS_REGISTRY_ADDRESS=0xfe03625ea880a8cba336f9b5ad6e15b0a3b5a939 npm run build", "build:ropsten": "cross-env ARAGON_ETH_NETWORK_TYPE=ropsten npm run build", "lint": "eslint ./src", - "test": "npm run lint && npm run jest", + "test": "npm run lint", "jest": "jest", "publish:major": "node scripts/publish major --only-content --files public/", "publish:minor": "node scripts/publish minor --only-content --files public/", diff --git a/scripts/build b/scripts/build index ec1bfbd79..994382739 100755 --- a/scripts/build +++ b/scripts/build @@ -4,6 +4,7 @@ require('dotenv').config() const version = require('../package.json').version const execute = require('child_process').execSync +const commitSha = (process.env.NOW_GITHUB_COMMIT_SHA || '').slice(0, 7) // First two arguments are node and script name const buildDir = process.argv[2] || 'public' @@ -13,7 +14,10 @@ execute(`copy-aragon-ui-assets -n aragon-ui ./${buildDir}`, { stdio: 'inherit', }) -process.env.ARAGON_PACKAGE_VERSION = version +// Commit sha is provided in nightly builds +process.env.ARAGON_PACKAGE_VERSION = commitSha + ? `${version}-${commitSha}` + : version execute( `parcel build src/index.html --out-dir ./${buildDir} --public-url ./ --no-cache`, { stdio: 'inherit' }