Deploy to server #85
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 to server | |
on: | |
workflow_run: | |
workflows: ["Build and Push Docker Images"] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up SSH key | |
env: | |
PRIVATE_KEY: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} | |
HOST: ${{ secrets.SERVER_SSH_HOST }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
ssh-keyscan -t rsa ${HOST} >> ~/.ssh/known_hosts | |
- name: Deploy to server | |
env: | |
PRIVATE_KEY: ${{ secrets.SERVER_SSH_PRIVATE_KEY }} | |
DEPLOY_USER: ${{ secrets.SERVER_SSH_USER }} | |
HOST: ${{ secrets.SERVER_SSH_HOST }} | |
CODE_PATH: ${{ vars.CODE_PATH }} | |
ACTOR: ${{ github.actor }} | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
ssh -i ~/.ssh/id_rsa ${DEPLOY_USER}@${HOST} "\ | |
docker login -u ${ACTOR} -p ${TOKEN} ghcr.io && \ | |
cd /home/deployuser/thirdeye/docker && \ | |
docker pull ghcr.io/thirdeye-dev/thirdeye:latest && \ | |
docker-compose -f /home/deployuser/thirdeye/docker/demo.yml down && \ | |
docker-compose -f /home/deployuser/thirdeye/docker/demo.yml up -d" |