Update .github/workflows/main.yml
Some checks failed
Build & Push Docker to Gitea Registry / build-and-push (push) Has been cancelled

This commit is contained in:
2025-12-23 23:20:15 +07:00
parent 354ea793c0
commit fe8ab74bd3

View File

@@ -1,122 +1,43 @@
name: Build ChatGPT-Discord-Bot
name: Build & Push Docker to Gitea Registry
on:
workflow_dispatch:
push:
branches: [ main ]
env:
REGISTRY: git.quocanh.me
OWNER: Coder-Vippro
IMAGE: chatgpt-discord-bot
TAG: latest
jobs:
tests:
runs-on: ubuntu-latest
env:
MONGODB_URI: ${{ secrets.MONGODB_URI }}
environment: Private Server Deploy
build-and-push:
runs-on: Ubuntu-local
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: '3.13.2'
cache: 'pip'
- name: Install dependencies
- name: Login to Gitea registry
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov flake8
pip install -r requirements.txt
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin
- name: Run unit tests with coverage
- name: Create or use buildx builder
run: |
python -m pytest tests/ --cov=src
docker buildx create --name ci-builder --use || docker buildx use ci-builder
docker buildx inspect --bootstrap
- name: Check dependencies for security issues
uses: pyupio/safety-action@v1.0.1
with:
api-key: ${{ secrets.SAFETY_API_KEY }}
build-amd64:
runs-on: ubuntu-latest
environment: Private Server Deploy
needs: tests
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: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image for amd64
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64
tags: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64
build-arm64:
runs-on: ubuntu-24.04-arm
environment: Private Server Deploy
needs: tests
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: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image for arm64
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/arm64
tags: ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
merge-manifest:
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push multi-arch manifest
- name: Build & push multi-arch image
run: |
docker buildx imagetools create -t ghcr.io/coder-vippro/chatgpt-discord-bot:latest \
ghcr.io/coder-vippro/chatgpt-discord-bot:latest-amd64 \
ghcr.io/coder-vippro/chatgpt-discord-bot:latest-arm64
docker buildx build \
--platform linux/amd64,linux/arm64 \
--tag ${REGISTRY}/${OWNER}/${IMAGE}:${TAG} \
--push \
.
deploy-notification:
runs-on: ubuntu-latest
needs: merge-manifest
if: ${{ success() }}
steps:
- name: Send deployment notification
uses: sarisia/actions-status-discord@v1
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
title: "✅ New deployment successful!"
description: |
Image: ${{ needs.build-and-push.outputs.image }}:${{ needs.build-and-push.outputs.version }}
Commit: ${{ github.sha }}
Repository: ${{ github.repository }}
color: 0x00ff00
username: GitHub Actions
- name: Verify pushed image (optional)
run: |
echo "Listing manifest for ${REGISTRY}/${OWNER}/${IMAGE}:${TAG}"
docker buildx imagetools inspect ${REGISTRY}/${OWNER}/${IMAGE}:${TAG}