mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-05-25 22:55:17 +01:00
56 lines
1.6 KiB
YAML
56 lines
1.6 KiB
YAML
name: Build, Update Version and Publish Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['*']
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Install bump2version
|
|
run: pip install bump2version
|
|
|
|
# Bump patch version, commit, and push back to repo (only on main branch)
|
|
- name: Bump version and push
|
|
if: github.ref == 'refs/heads/main'
|
|
run: |
|
|
bump2version patch --allow-dirty
|
|
git push origin main --follow-tags
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Registry
|
|
run: echo "${{ secrets.PASSWORD }}" | docker login ${{ secrets.REGISTRY }} -u "${{ secrets.USERNAME }}" --password-stdin
|
|
|
|
- name: Get version from file
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(python -c "import myproject.__version__ as v; print(v.__version__)")
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and Push Docker Images
|
|
run: |
|
|
IMAGE_NAME="ai-frame-image-server"
|
|
REGISTRY="${{ secrets.REGISTRY }}"
|
|
USERNAME="${{ secrets.USERNAME }}"
|
|
VERSION="${{ steps.get_version.outputs.version }}"
|
|
IMAGE_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:$VERSION"
|
|
|
|
echo "🔧 Building $IMAGE_TAG"
|
|
docker build -t $IMAGE_TAG .
|
|
|
|
echo "📤 Pushing $IMAGE_TAG"
|
|
docker push $IMAGE_TAG
|