Skip to content

feat(casino): Информация о командах для казино #220

feat(casino): Информация о командах для казино

feat(casino): Информация о командах для казино #220

name: Docker CI/CD
on:
push:
branches:
- main
- dev
- feature/**
- fix/**
tags:
- 'v*.*.*' # Build on version tags like v1.2.3
env:
REGISTRY: ghcr.io
IMAGE_NAME: stp-team/stpsher
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=short
type=ref,event=branch
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
deploy:
runs-on: ubuntu-latest
permissions:
contents: none
environment:
name: Server
needs: build-and-push
if: github.ref_name == 'main'
steps:
- name: Deploy to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
set -e
cd /home/stp/projects/stpsher
echo "Pulling latest image..."
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
echo "Restarting containers..."
docker compose up -d
echo "Cleaning up..."
docker system prune -af