diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 2bec57f9d5..0000000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Run tests -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [14.x] - steps: - - uses: actions/checkout@v2 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: Install dependencies - run: sudo apt update && sudo apt-get install -y libudev-dev libusb-1.0-0-dev - - run: yarn install - working-directory: ./contracts - - run: yarn run lint - working-directory: ./contracts - - run: yarn prettier:check - working-directory: ./contracts - - run: yarn run test - working-directory: ./contracts - - run: yarn install - working-directory: ./dapp - - run: yarn prettier:check - working-directory: ./dapp diff --git a/.github/workflows/ousd.yml b/.github/workflows/ousd.yml index 40417d290c..26d5b100a2 100644 --- a/.github/workflows/ousd.yml +++ b/.github/workflows/ousd.yml @@ -146,4 +146,65 @@ jobs: env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: - args: --severity-threshold=high --all-projects \ No newline at end of file + args: --severity-threshold=high --all-projects + + build-image: + name: "Deploy App" + runs-on: ubuntu-latest + needs: [contracts-lint, dapp-lint] + env: + HEROKU_TOKEN: ${{ secrets.HEROKU_TOKEN }} + CURR_BRANCH: ${{ github.ref_name }} + if: ${{ contains(fromJSON('["master", "staging", "stable"]'), github.ref_name) }} + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Run Docker Login + run: docker login --username =_ --password=$HEROKU_TOKEN registry.heroku.com + + - name: Identify Heroku App Name + shell: bash + run: + if [[ $CURR_BRANCH == "stable" ]]; then + echo "HEROKU_APP_NAME=ousd-dapp" >> $GITHUB_ENV; + else + echo "HEROKU_APP_NAME=ousd-dapp-staging" >> $GITHUB_ENV; + fi; + id: heroku_app + + - name: Heroku Login + uses: akhileshns/heroku-deploy@v3.12.12 + if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }} + with: + justlogin: true + heroku_api_key: ${{secrets.HEROKU_TOKEN}} + heroku_app_name: ${{env.HEROKU_APP_NAME}} + heroku_email: ${{secrets.HEROKU_EMAIL}} + + - name: Extract Deployment Env + env: + HEROKU_APP_NAME: ${{env.HEROKU_APP_NAME}} + working-directory: dapp + run: heroku config -s -a $HEROKU_APP_NAME > deploy.env + - name: Build and Push + uses: docker/build-push-action@v3 + if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }} + env: + NODE_ENV: production + with: + context: . + push: true + tags: registry.heroku.com/${{env.HEROKU_APP_NAME}}/web + provenance: false + + - name: Deploy to Heroku + if: ${{ contains(fromJSON('["staging", "stable"]'), github.ref_name) }} + env: + HEROKU_APP_NAME: ${{env.HEROKU_APP_NAME}} + run: heroku container:release web -a $HEROKU_APP_NAME \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..a0fd9dd5a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM node:16-alpine + +# Install Git +RUN apk update +RUN apk add git + +# Copy files over +WORKDIR /app +COPY contracts ./contracts +COPY dapp ./dapp + +# Build contract files +WORKDIR /app/contracts +RUN yarn install +RUN yarn deploy + +# Build DApp +WORKDIR /app/dapp +RUN yarn install +RUN NODE_ENV=production yarn build + +CMD ["yarn", "start"] diff --git a/dapp/package.json b/dapp/package.json index 1b0aff6814..fcabc2bef1 100644 --- a/dapp/package.json +++ b/dapp/package.json @@ -13,7 +13,7 @@ "ipfs-export": "DEPLOY_MODE=ipfs yarn run build && next export", "start": "per-env", "start:development": "NODE_ENV=development ETHEREUM_RPC_PROVIDER=http://localhost:8545 next dev", - "start:production": "NODE_ENV=production next start -p 8080", + "start:production": "NODE_ENV=production next start -p $PORT", "gcp-build": "next build", "encrypt-secrets:prod": "gcloud kms encrypt --ciphertext-file=prod.secrets.enc --plaintext-file=prod.env --location=global --keyring=origin --key=cloudbuild", "decrypt-secrets:prod": "gcloud kms decrypt --ciphertext-file=prod.secrets.enc --plaintext-file=prod.env --location=global --keyring=origin --key=cloudbuild", diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000000..8eec25b9c9 --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile