mirror of
https://github.com/nirvana-7777/script.service.ultimate.git
synced 2026-09-16 06:02:35 +02:00
87 lines
2.4 KiB
YAML
87 lines
2.4 KiB
YAML
name: Docker Build and Publish
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, main ]
|
|
tags: [ 'v*' ]
|
|
pull_request:
|
|
branches: [ master, main ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5 # v5 runs on Node 24
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v6 # v6 runs on Node 24
|
|
with:
|
|
python-version: '3.11'
|
|
cache: 'pip'
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
pip install -r requirements.txt
|
|
pip install pytest pytest-asyncio
|
|
|
|
- name: Run tests (if any)
|
|
run: |
|
|
echo "No tests configured yet"
|
|
|
|
docker:
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name != 'pull_request'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5 # v5 runs on Node 24
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v4 # v4 runs on Node 24
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v4 # v4 runs on Node 24
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v6 # v6 runs on Node 24
|
|
with:
|
|
images: nirvana777/ultimate-backend
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=ref,event=tag
|
|
type=ref,event=pr
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6 # v6 runs on Node 24
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
platforms: linux/amd64,linux/arm64
|
|
build-args: |
|
|
APP_USER=ultimate
|
|
|
|
notify:
|
|
runs-on: ubuntu-latest
|
|
needs: [test, docker]
|
|
if: always()
|
|
steps:
|
|
- name: Workflow status
|
|
run: |
|
|
echo "Test job: ${{ needs.test.result }}"
|
|
echo "Docker job: ${{ needs.docker.result }}" |