|
| 1 | +# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: Node.js CI |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [master] |
| 9 | + |
| 10 | +jobs: |
| 11 | + cleanup: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + timeout-minutes: 10 |
| 14 | + steps: |
| 15 | + - name: Remove old artifacts |
| 16 | + uses: c-hive/gha-remove-artifacts@v1 |
| 17 | + with: |
| 18 | + age: 0 days |
| 19 | + skip-tags: true |
| 20 | + skip-recent: 2 |
| 21 | + |
| 22 | + build: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - uses: actions/setup-node@v1 |
| 27 | + with: |
| 28 | + node-version: 14 |
| 29 | + - run: yarn install |
| 30 | + - name: Linting JS |
| 31 | + run: yarn lint |
| 32 | + - name: Build |
| 33 | + run: yarn generate |
| 34 | + env: |
| 35 | + INFURA_KEY: ${{ secrets.INFURA_KEY }} |
| 36 | + ALCHEMY_MAINNET_KEY: ${{ secrets.ALCHEMY_MAINNET_KEY }} |
| 37 | + ALCHEMY_POLYGON_KEY: ${{ secrets.ALCHEMY_POLYGON_KEY }} |
| 38 | + ALCHEMY_OPTIMISM_KEY: ${{ secrets.ALCHEMY_OPTIMISM_KEY }} |
| 39 | + ALCHEMY_ARBITRUM_KEY: ${{ secrets.ALCHEMY_ARBITRUM_KEY }} |
| 40 | + ALCHEMY_GOERLI_KEY: ${{ secrets.ALCHEMY_GOERLI_KEY }} |
| 41 | + WC_BRIDGE: ${{ secrets.WC_BRIDGE }} |
| 42 | + OLD_STORE_NAME: ${{ secrets.OLD_STORE_NAME }} |
| 43 | + STORE_NAME: ${{ secrets.STORE_NAME }} |
| 44 | + APP_ENS_NAME: ${{ secrets.APP_ENS_NAME }} |
| 45 | + - name: Upload artefact |
| 46 | + |
| 47 | + with: |
| 48 | + name: dist |
| 49 | + path: dist |
| 50 | + |
| 51 | + deploy-minified: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: build |
| 54 | + steps: |
| 55 | + - name: Download artifact `dist` |
| 56 | + uses: actions/download-artifact@v1 |
| 57 | + with: |
| 58 | + name: dist |
| 59 | + - name: Add SSH key |
| 60 | + uses: webfactory/[email protected] |
| 61 | + env: |
| 62 | + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' |
| 63 | + with: |
| 64 | + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 65 | + - name: Add git remote |
| 66 | + run: | |
| 67 | + git init |
| 68 | + git config --local user.email "[email protected]" |
| 69 | + git config --local user.name "GitHub" |
| 70 | + echo dist > .gitignore && git add .gitignore && git commit -m push-dir |
| 71 | + git remote add ui [email protected]:tornadocash/ui-minified.git |
| 72 | + - name: Deploying... |
| 73 | + run: npx push-dir --dir=dist --branch=master --cleanup --remote=ui |
| 74 | + |
| 75 | + deploy-docker: |
| 76 | + runs-on: ubuntu-latest |
| 77 | + needs: build |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v2 |
| 80 | + - name: Download artifact `dist` |
| 81 | + uses: actions/download-artifact@v1 |
| 82 | + with: |
| 83 | + name: dist |
| 84 | + - name: Build and push Docker image |
| 85 | + |
| 86 | + with: |
| 87 | + path: dist |
| 88 | + dockerfile: Dockerfile |
| 89 | + repository: tornadocash/ui |
| 90 | + tags: latest |
| 91 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 93 | + |
| 94 | + deploy-ipfs: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + needs: build |
| 97 | + steps: |
| 98 | + - uses: actions/checkout@v2 |
| 99 | + - uses: actions/setup-node@v1 |
| 100 | + with: |
| 101 | + node-version: 14 |
| 102 | + - run: yarn install |
| 103 | + - name: Download artifact `dist` |
| 104 | + uses: actions/download-artifact@v1 |
| 105 | + with: |
| 106 | + name: dist |
| 107 | + - name: Upload to IPFS |
| 108 | + id: upload |
| 109 | + run: yarn ipfsUpload dist |
| 110 | + env: |
| 111 | + PINATA_API_KEY: ${{ secrets.PINATA_API_KEY }} |
| 112 | + PINATA_SECRET_API_KEY: ${{ secrets.PINATA_SECRET_API_KEY }} |
| 113 | + |
| 114 | + notify: |
| 115 | + runs-on: ubuntu-latest |
| 116 | + if: always() |
| 117 | + needs: |
| 118 | + - deploy-minified |
| 119 | + - deploy-docker |
| 120 | + - deploy-ipfs |
| 121 | + steps: |
| 122 | + # ${{ env.WORKFLOW_CONCLUSION }} # neutral, success, cancelled, timed_out, failure |
| 123 | + - uses: technote-space/workflow-conclusion-action@v2 |
| 124 | + - name: Set short SHA |
| 125 | + id: vars |
| 126 | + run: echo "::set-output name=sha_short::$(echo ${GITHUB_SHA:0:7})" |
| 127 | + - name: Telegram Message Notify |
| 128 | + |
| 129 | + if: ${{ env.WORKFLOW_CONCLUSION == 'success' }} |
| 130 | + with: |
| 131 | + to: ${{ secrets.TELEGRAM_CHAT_ID }} |
| 132 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN}} |
| 133 | + message: 🚀 Deployed commit [${{ steps.vars.outputs.sha_short }}](https://github.com/tornadocash/tornado-cash-ui/commit/${{ github.sha }}) of tornado.cash UI |
| 134 | + format: markdown |
| 135 | + - name: Telegram Failure Notification |
| 136 | + |
| 137 | + if: ${{ env.WORKFLOW_CONCLUSION == 'failure' || env.WORKFLOW_CONCLUSION == 'timed_out' || env.WORKFLOW_CONCLUSION == 'neutral' }} |
| 138 | + with: |
| 139 | + message: ❗ Build failed for [${{ github.repository }}](https://github.com/${{ github.repository }}/actions) because of ${{ github.actor }} |
| 140 | + format: markdown |
| 141 | + to: ${{ secrets.TELEGRAM_CHAT_ID }} |
| 142 | + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} |
0 commit comments