classic-ui-dev/.github/workflows/nodejs.yml
Danil Kovtonyuk 44f31f8b9f
init
2022-04-22 13:14:19 +10:00

143 lines
4.7 KiB
YAML

# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [master]
jobs:
cleanup:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Remove old artifacts
uses: c-hive/gha-remove-artifacts@v1
with:
age: 0 days
skip-tags: true
skip-recent: 2
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- run: yarn install
- name: Linting JS
run: yarn lint
- name: Build
run: yarn generate
env:
INFURA_KEY: ${{ secrets.INFURA_KEY }}
ALCHEMY_MAINNET_KEY: ${{ secrets.ALCHEMY_MAINNET_KEY }}
ALCHEMY_POLYGON_KEY: ${{ secrets.ALCHEMY_POLYGON_KEY }}
ALCHEMY_OPTIMISM_KEY: ${{ secrets.ALCHEMY_OPTIMISM_KEY }}
ALCHEMY_ARBITRUM_KEY: ${{ secrets.ALCHEMY_ARBITRUM_KEY }}
ALCHEMY_GOERLI_KEY: ${{ secrets.ALCHEMY_GOERLI_KEY }}
WC_BRIDGE: ${{ secrets.WC_BRIDGE }}
OLD_STORE_NAME: ${{ secrets.OLD_STORE_NAME }}
STORE_NAME: ${{ secrets.STORE_NAME }}
APP_ENS_NAME: ${{ secrets.APP_ENS_NAME }}
- name: Upload artefact
uses: actions/upload-artifact@v1.0.0
with:
name: dist
path: dist
deploy-minified:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact `dist`
uses: actions/download-artifact@v1
with:
name: dist
- name: Add SSH key
uses: webfactory/ssh-agent@v0.2.0
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add git remote
run: |
git init
git config --local user.email "actions@github.com"
git config --local user.name "GitHub"
echo dist > .gitignore && git add .gitignore && git commit -m push-dir
git remote add ui git@github.com:tornadocash/ui-minified.git
- name: Deploying...
run: npx push-dir --dir=dist --branch=master --cleanup --remote=ui
deploy-docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- name: Download artifact `dist`
uses: actions/download-artifact@v1
with:
name: dist
- name: Build and push Docker image
uses: docker/build-push-action@v1.1.0
with:
path: dist
dockerfile: Dockerfile
repository: tornadocash/ui
tags: latest
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
deploy-ipfs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 14
- run: yarn install
- name: Download artifact `dist`
uses: actions/download-artifact@v1
with:
name: dist
- name: Upload to IPFS
id: upload
run: yarn ipfsUpload dist
env:
PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }}
PINATA_SECRET_API_KEY: ${{ secrets.PINATA_SECRET_API_KEY }}
notify:
runs-on: ubuntu-latest
if: always()
needs:
- deploy-minified
- deploy-docker
- deploy-ipfs
steps:
# ${{ env.WORKFLOW_CONCLUSION }} # neutral, success, cancelled, timed_out, failure
- uses: technote-space/workflow-conclusion-action@v2
- name: Set short SHA
id: vars
run: echo "::set-output name=sha_short::$(echo ${GITHUB_SHA:0:7})"
- name: Telegram Message Notify
uses: appleboy/telegram-action@v0.1.1
if: ${{ env.WORKFLOW_CONCLUSION == 'success' }}
with:
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN}}
message: 🚀 Deployed commit [${{ steps.vars.outputs.sha_short }}](https://github.com/tornadocash/tornado-cash-ui/commit/${{ github.sha }}) of tornado.cash UI
format: markdown
- name: Telegram Failure Notification
uses: appleboy/telegram-action@v0.1.1
if: ${{ env.WORKFLOW_CONCLUSION == 'failure' || env.WORKFLOW_CONCLUSION == 'timed_out' || env.WORKFLOW_CONCLUSION == 'neutral' }}
with:
message: ❗ Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }}
format: markdown
to: ${{ secrets.TELEGRAM_CHAT_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}