Deploy Production #29
This file contains 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 Production | |
on: | |
workflow_dispatch: | |
inputs: | |
bot: | |
type: choice | |
description: Bot | |
options: | |
- mozart | |
- wagner | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
known_hosts: "just-a-placeholder-so-we-dont-get-errors" | |
- name: Adding Known Hosts | |
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
- name: Copy sources to server | |
run: rsync -avz ./ root@${{ secrets.SSH_HOST }}:/home/ci/apps/evobot_${{ github.event.inputs.bot }}_fresh | |
- name: Build & run application | |
env: | |
METRICS_PORT: ${{ fromJSON('{"mozart":"9100","wagner":"9200"}')[github.event.inputs.bot] }} | |
run: >- | |
ssh root@${{ secrets.SSH_HOST }} | |
' | |
uptime; | |
cd /home/ci/apps; | |
rm -rf evobot_${{ github.event.inputs.bot }}_prev; | |
mv evobot_${{ github.event.inputs.bot }} evobot_${{ github.event.inputs.bot }}_prev; | |
mv evobot_${{ github.event.inputs.bot }}_fresh evobot_${{ github.event.inputs.bot }}; | |
cp envs/evobot_${{ github.event.inputs.bot }}.config.json evobot_${{ github.event.inputs.bot }}/config.json; | |
cd evobot_${{ github.event.inputs.bot }}; | |
docker build --no-cache -t evobot:${{ github.event.inputs.bot }} .; | |
docker stop ${{ github.event.inputs.bot }}; | |
docker rm ${{ github.event.inputs.bot }}; | |
docker run -d -p 127.0.0.1:${{ env.METRICS_PORT }}:3000 --name=${{ github.event.inputs.bot }} --restart=always evobot:${{ github.event.inputs.bot }}; | |
' |