refactor: Update to match facefusion-api gitea workflow, remove test jobs
This commit is contained in:
@@ -1,94 +1,141 @@
|
|||||||
name: Docker Build and Publish
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- develop
|
- develop
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Custom tag for the image'
|
||||||
|
required: false
|
||||||
|
default: 'manual'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: gitea.example.com
|
REGISTRY: dev.pivoine.art
|
||||||
IMAGE_NAME: realesrgan-api
|
IMAGE_NAME: valknar/realesrgan-api
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build-gpu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
packages: write
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
variant: [cpu, gpu]
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
- name: Log in to Gitea Registry
|
- name: Log in to Gitea Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ secrets.GITEA_USERNAME }}
|
username: ${{ gitea.actor }}
|
||||||
password: ${{ secrets.GITEA_TOKEN }}
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Generate image tags
|
- name: Extract metadata (GPU)
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
uses: docker/metadata-action@v5
|
||||||
COMMIT_SHA=${{ github.sha }}
|
with:
|
||||||
BRANCH=${{ github.ref_name }}
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${COMMIT_SHA:0:7}-${{ matrix.variant }}"
|
tags: |
|
||||||
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${BRANCH}-${{ matrix.variant }}"
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
|
type=ref,event=branch
|
||||||
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-${{ matrix.variant }}"
|
type=ref,event=pr
|
||||||
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
|
type=semver,pattern={{version}}
|
||||||
fi
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
|
type=semver,pattern={{major}}
|
||||||
|
type=sha,prefix={{branch}}-
|
||||||
|
type=raw,value=${{ gitea.event.inputs.tag }},enable=${{ gitea.event_name == 'workflow_dispatch' }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=realesrgan-api
|
||||||
|
org.opencontainers.image.description=REST API for Real-ESRGAN image upscaling (GPU)
|
||||||
|
org.opencontainers.image.vendor=valknar
|
||||||
|
|
||||||
- name: Build and push Docker image (${{ matrix.variant }})
|
- name: Build and push GPU image
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
platforms: linux/amd64
|
||||||
|
push: ${{ gitea.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
build-args: |
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
VARIANT=${{ matrix.variant }}
|
build-args: VARIANT=gpu
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.variant }}
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-gpu
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.variant }},mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-gpu,mode=max
|
||||||
|
|
||||||
test:
|
- name: Summary
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
|
run: |
|
||||||
|
echo "### GPU Image Published" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "**Tags:**" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "${{ steps.meta.outputs.tags }}" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITEA_STEP_SUMMARY
|
||||||
|
|
||||||
|
build-cpu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.12'
|
submodules: recursive
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Set up Docker Buildx
|
||||||
run: |
|
uses: docker/setup-buildx-action@v3
|
||||||
python -m pip install --upgrade pip
|
with:
|
||||||
pip install -r requirements.txt -r requirements-cpu.txt
|
platforms: linux/amd64
|
||||||
pip install pytest pytest-asyncio httpx
|
|
||||||
|
|
||||||
- name: Lint with flake8
|
- name: Log in to Gitea Container Registry
|
||||||
run: |
|
uses: docker/login-action@v3
|
||||||
pip install flake8
|
with:
|
||||||
flake8 app --count --select=E9,F63,F7,F82 --show-source --statistics
|
registry: ${{ env.REGISTRY }}
|
||||||
flake8 app --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
username: ${{ gitea.actor }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
- name: Type check with mypy
|
- name: Extract metadata (CPU)
|
||||||
run: |
|
id: meta-cpu
|
||||||
pip install mypy
|
uses: docker/metadata-action@v5
|
||||||
mypy app --ignore-missing-imports || true
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
flavor: suffix=-cpu
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest-cpu,enable={{is_default_branch}}
|
||||||
|
type=ref,event=branch,suffix=-cpu
|
||||||
|
type=ref,event=pr,suffix=-cpu
|
||||||
|
type=semver,pattern={{version}},suffix=-cpu
|
||||||
|
type=sha,prefix={{branch}}-,suffix=-cpu
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.title=realesrgan-api
|
||||||
|
org.opencontainers.image.description=REST API for Real-ESRGAN image upscaling (CPU)
|
||||||
|
org.opencontainers.image.vendor=valknar
|
||||||
|
|
||||||
- name: Run tests
|
- name: Build and push CPU image
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: ${{ gitea.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta-cpu.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta-cpu.outputs.labels }}
|
||||||
|
build-args: VARIANT=cpu
|
||||||
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-cpu
|
||||||
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-cpu,mode=max
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
if: gitea.event_name != 'pull_request'
|
||||||
run: |
|
run: |
|
||||||
pytest tests/ -v || true
|
echo "### CPU Image Published" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "**Tags:**" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "${{ steps.meta-cpu.outputs.tags }}" >> $GITEA_STEP_SUMMARY
|
||||||
|
echo "\`\`\`" >> $GITEA_STEP_SUMMARY
|
||||||
|
|||||||
Reference in New Issue
Block a user