Skip to content

Deploy artifacts to mainnet environment #3

Deploy artifacts to mainnet environment

Deploy artifacts to mainnet environment #3

name: deploy-to-mainnet
run-name: Deploy artifacts to mainnet environment
on:
# Only run this workflow automatically after ci workflow on main branch.
workflow_run:
workflows: [ci]
types: [completed]
branches: [main]
jobs:
deploy-and-restart:
runs-on: sg
environment: mainnet
strategy:
matrix:
target: [SERVER_1, SERVER_2]
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Download Artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
run_number: ${{ github.event.workflow_run.run_number }}
name: thq-${{ github.event.workflow_run.head_commit.id }}.zip
- name: Unzip artifact
run: rm -rf ./dist && unzip -q thq-${{ github.event.workflow_run.head_commit.id }}.zip -d ./dist
- name: Deploy to server contract
run: ls -la ./dist && rsync -a ./dist/ ${{ vars[matrix.target] }}:/mnt/ckb/ckb-time-generator
- name: Restart pm2 on server contract
run: ssh ${{ vars[matrix.target] }} 'source ~/.zshrc && cd /mnt/ckb/ckb-time-generator && npm install --omit=dev && npm run reload_mainnet'