-
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.
- Loading branch information
1 parent
3a1588d
commit 21e9daa
Showing
10 changed files
with
140 additions
and
63 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,75 @@ | ||
name: Main workflow | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build_and_push: | ||
name: Build Docker images and push them to DockerHub | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- image_name: valeevilja/cppbot:v1 | ||
dockerfile: Dockerfile | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/[email protected] | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ matrix.image_name }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
file: ${{ matrix.dockerfile }} | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
deploy: | ||
name: Deploy to server | ||
runs-on: ubuntu-latest | ||
needs: build_and_push | ||
steps: | ||
- name: executing remote ssh commands to deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USER }} | ||
key: ${{ secrets.SSH_KEY }} | ||
passphrase: ${{ secrets.PASSPHRASE }} | ||
script: | | ||
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cppbot:v1 | ||
sudo docker-compose down | ||
touch .env | ||
echo BOT_TOKEN=${{ secrets.BOT_TOKEN }} >> .env | ||
echo POSTGRES_USER=${{ secrets.POSTGRES_USER }} >> .env | ||
echo POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }} >> .env | ||
echo POSTGRES_DB=${{ secrets.POSTGRES_DB }} >> .env | ||
echo POSTGRES_PORT=${{ secrets.POSTGRES_PORT }} >> .env | ||
echo POSTGRES_HOST=${{ secrets.POSTGRES_HOST }} >> .env | ||
echo ADMIN_CHAT_ID=${{ secrets.ADMIN_CHAT_ID }} >> .env | ||
sudo docker-compose up -d --build | ||
send_message: | ||
runs-on: ubuntu-latest | ||
needs: deploy | ||
steps: | ||
- name: send message | ||
uses: appleboy/telegram-action@master | ||
with: | ||
to: ${{ secrets.TELEGRAM_TO }} | ||
token: ${{ secrets.TELEGRAM_TOKEN }} | ||
message: ${{ github.workflow }} успешно выполнен! |
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 |
---|---|---|
|
@@ -13,5 +13,6 @@ | |
|
||
build/ | ||
data/ | ||
cppinfra/ | ||
.env | ||
todo.txt |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
project(cppbot) | ||
|
||
|
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
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
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
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
Oops, something went wrong.