Skip to content

(^=◕ᴥ◕=^) telegram bot and simple refactor github workflow CI #11

(^=◕ᴥ◕=^) telegram bot and simple refactor github workflow CI

(^=◕ᴥ◕=^) telegram bot and simple refactor github workflow CI #11

name: Publish Docker images
on:
push:
branches: [ main ]
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push srv image
uses: docker/build-push-action@v2
with:
context: ./server
file: ./server/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-server:latest
build-args:
SRVNAME=${{ secrets.SRV_HOSTNAME }}
- name: Build and push frnt image
uses: docker/build-push-action@v2
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-frontend:latest
build-args:
VITE_APP_API_URL=${{ secrets.PROTOCOL }}://${{ secrets.SRV_HOSTNAME }}
- name: Build and push bot image
uses: docker/build-push-action@v2
with:
context: ./bot
file: ./bot/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-bot:latest
deploy:
needs: build-and-push
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Stop and remove previous deployment
run: docker-compose -f docker-compose.prod.yml down --rmi all
- name: Create .env file
run: |
echo ADDRESS=0.0.0.0 >> .env
echo PORT=${{ secrets.SRV_PORT }} >> .env
echo UNIT=1 >> .env
echo TYPE=1 >> .env
echo PROTOCOL=${{ secrets.PROTOCOL }} >> .env
echo SRV_HOSTNAME=${{ secrets.SRV_HOSTNAME }} >> .env
echo SRV_PORT=${{ secrets.SRV_PORT }} >> .env
echo FRNT_PORT=${{ secrets.FRNT_PORT }} >> .env
echo PROTOCOL_API=${{ secrets.PROTOCOL_API }} >> .env
echo BOT_TOKEN=${{ secrets.BOT_TOKEN }} >> .env
echo API_SERVER=${{ secrets.PROTOCOL }}://${{ secrets.SRV_HOSTNAME }} >> .env
echo BOT_PORT=${{ secrets.BOT_PORT }} >> .env
echo BOT_ADDRESS=${{ secrets.BOT_ADDRESS }} >> .env
echo USE_WEBHOOKS=${{ secrets.USE_WEBHOOKS }} >> .env
echo WEBHOOK_URL=${{ secrets.WEBHOOK_URL }} >> .env
- name: Deploy to server
run: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-frontend:latest
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-server:latest
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cuteconverter-bot:latest
docker-compose -f docker-compose.prod.yml up -d