forked from Andrey-Ved/CaptchaBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Andrey-Ved#4 from OldCodersClub/main
build(workflows): add 'Deploy to VPS' actions
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
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
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; |