Skip to content

Commit

Permalink
chore: adjust deployment workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdesu committed Sep 8, 2023
1 parent 6124ce4 commit 9ec71f5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 72 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: deploy
run-name: Deploy artifacts

on:
# Only run this workflow automatically after ci workflow on main branch.
workflow_run:
workflows: [ci]
types: [completed]
branches: [main, develop]

jobs:
deploy-to-mainnet:
runs-on: sg
if: github.event.workflow_run.conclusion == 'success' && github.ref_name == 'main'
environment: mainnet
strategy:
matrix:
target: [SERVER_1, SERVER_2]
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'

deploy-to-testnet:
runs-on: sg
if: github.event.workflow_run.conclusion == 'success' && github.ref_name == 'develop'
environment: testnet
strategy:
matrix:
target: [SERVER_1, SERVER_2]
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'
36 changes: 0 additions & 36 deletions .github/workflows/deploy-to-mainnet.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions .github/workflows/deploy-to-testnet.yaml

This file was deleted.

0 comments on commit 9ec71f5

Please sign in to comment.