Deploy staging submitter #68
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy staging submitter | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 | |
| - uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2 | |
| with: | |
| bun-version: '1.2.4' | |
| - name: Build code | |
| run: | | |
| make submitter.build | |
| - name: Copy files to server | |
| uses: appleboy/scp-action@917f8b81dfc1ccd331fef9e2d61bdc6c8be94634 # v0.1.7 | |
| with: | |
| host: ${{ secrets.SERVER_2_HOST }} | |
| username: ${{ secrets.SERVER_2_USERNAME }} | |
| key: ${{ secrets.SERVER_2_KEY }} | |
| port: ${{ secrets.SERVER_2_PORT }} | |
| source: "apps/submitter/build/*" | |
| target: /home/deployer/happy-staging-submitter | |
| strip_components: 2 | |
| rm: true | |
| debug: true | |
| - name: Deploy submitter to server | |
| uses: appleboy/ssh-action@25ce8cbbcb08177468c7ff7ec5cbfa236f9341e1 # v1.1.0 | |
| with: | |
| host: ${{ secrets.SERVER_2_HOST }} | |
| username: ${{ secrets.SERVER_2_USERNAME }} | |
| key: ${{ secrets.SERVER_2_KEY }} | |
| port: ${{ secrets.SERVER_2_PORT }} | |
| script_stop: true | |
| script: | | |
| chmod -R o+rX /home/deployer/happy-staging-submitter | |
| rm -rf /tmp/happy-staging-submitter | |
| mv /home/deployer/happy-staging-submitter /tmp | |
| sudo -u staging_submitter bash -c ' | |
| rm -rf /home/staging_submitter/build | |
| cp -r /tmp/happy-staging-submitter/* /home/staging_submitter/build | |
| cat > /home/staging_submitter/build/.env <<-EOF | |
| EXECUTOR_KEYS=${{ secrets.STAGING_SUBMITTER_EXECUTOR_KEYS }} | |
| PRIVATE_KEY_ACCOUNT_DEPLOYER=${{ secrets.STAGING_SUBMITTER_PRIVATE_KEY_ACCOUNT_DEPLOYER }} | |
| SLACK_WEBHOOK_URL=${{ secrets.STAGING_SUBMITTER_SLACK_WEBHOOK_URL }} | |
| APP_PORT=49535 | |
| LOG_LEVEL=TRACE | |
| DATABASE_URL=/home/staging_submitter/db.sqlite | |
| CHAIN_ID=216 | |
| NODE_ENV=staging | |
| RPC_URLS=wss://rpc.testnet.happy.tech/ws,https://rpc.testnet.happy.tech/http | |
| USE_STAGING_CONTRACTS=true | |
| TRACES_ENDPOINT=http://localhost:4318/v1/traces | |
| PROMETHEUS_PORT=9091 | |
| LOG_COLORS=false | |
| LOG_TIMESTAMPS=false | |
| EOF | |
| # cf. https://github.com/appleboy/drone-ssh/issues/175 | |
| sed -i '/DRONE_SSH_PREV_COMMAND_EXIT_CODE/d' /home/staging_submitter/build/.env | |
| cd /home/staging_submitter/build | |
| bun migrate.es.js | |
| ' | |
| rm -rf /tmp/happy-staging-submitter | |
| sudo /bin/systemctl restart staging-submitter.service |