Skip to content

Commit

Permalink
Merge pull request Andrey-Ved#4 from OldCodersClub/main
Browse files Browse the repository at this point in the history
build(workflows): add 'Deploy to VPS' actions
  • Loading branch information
Andrey-Ved authored Mar 31, 2023
2 parents 063013b + 823924f commit 1886255
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/deploy_to_vps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy to VPS

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.CAPTCHA_BOT_SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.CAPTCHA_BOT_SSH_HOST }} >> ~/.ssh/known_hosts

- name: Run command on remote server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.CAPTCHA_BOT_SSH_HOST }}
username: ${{ secrets.CAPTCHA_BOT_SSH_USER }}
key: ${{ secrets.CAPTCHA_BOT_SSH_PRIVATE_KEY }}
script: |
echo '--- START WORK ON REMOTE SERVER ---';
cd CaptchaBot;
echo '--- EXPORT VARIABLES ---';
export BOT_TOKEN=${{ secrets.CAPTCHA_BOT_TOKEN }};
export CHAT_ID_1=${{ vars.CHAT_ID_1 }}
export CHAT_ID_2=${{ vars.CHAT_ID_2 }}
export CHAT_ID_3=${{ vars.CHAT_ID_3 }}
export CHAT_ID_4=${{ vars.CHAT_ID_4 }}
echo '--- LIST OF FILES ---';
ls -al;
echo '--- GIT PULL ---'
git pull;
echo '--- DOCKER OPERATIONS ---';
docker-compose down;
docker rmi captcha_bot;
echo '--- LIST OF DOCKER CONTAINERS ---';
docker ps -a;
echo '--- UP CONTAINER ---';
docker-compose up -d;
echo '--- LIST OF DOCKER CONTAINERS ---';
docker ps -a;

0 comments on commit 1886255

Please sign in to comment.