add ci-cd

This commit is contained in:
2025-04-21 11:52:43 +03:00
parent efafe455b4
commit a656a4553b
6 changed files with 109 additions and 0 deletions

48
.github/workflows/main.yaml vendored Normal file
View File

@@ -0,0 +1,48 @@
name: Build and deploy
on:
push:
branches:
- 'main'
jobs:
build:
runs-on: self-hosted
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: smallbuster/fe-docs:latest
deploy:
runs-on: self-hosted
needs: build
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Pull Docker image from Docker Hub
run: |
docker pull smallbuster/fe-docs:latest
- name: Stop and remove existing container
run: |
docker stop fe-docs || true && docker rm fe-docs || true
- name: Run Docker container
run: |
docker run -d --restart unless-stopped \
--name fe-docs smallbuster/fe-docs:latest