mirror of
https://github.com/karl0ss/ai_image_frame_server.git
synced 2025-05-27 15:22:00 +01:00
revery workflow
This commit is contained in:
parent
7dd90bb032
commit
cd5306814c
50
.github/workflows/docker-publish.yml
vendored
50
.github/workflows/docker-publish.yml
vendored
@ -1,55 +1,47 @@
|
|||||||
name: Build, Update Version and Publish Docker Image
|
name: Build and Publish Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
tags: ['*']
|
tags: ['*'] # triggers on any tag push
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to Docker Registry
|
- name: Log in to Docker Registry
|
||||||
run: echo "${{ secrets.PASSWORD }}" | docker login ${{ secrets.REGISTRY }} -u "${{ secrets.USERNAME }}" --password-stdin
|
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
|
- name: Build and Push Docker Images
|
||||||
run: |
|
run: |
|
||||||
IMAGE_NAME="ai-frame-image-server"
|
IMAGE_NAME="ai-frame-image-server"
|
||||||
REGISTRY="${{ secrets.REGISTRY }}"
|
REGISTRY="${{ secrets.REGISTRY }}"
|
||||||
USERNAME="${{ secrets.USERNAME }}"
|
USERNAME="${{ secrets.USERNAME }}"
|
||||||
VERSION="${{ steps.get_version.outputs.version }}"
|
IMAGE_LATEST="$REGISTRY/$USERNAME/$IMAGE_NAME:latest"
|
||||||
IMAGE_TAG="$REGISTRY/$USERNAME/$IMAGE_NAME:$VERSION"
|
|
||||||
|
|
||||||
echo "🔧 Building $IMAGE_TAG"
|
# Always build and tag as latest
|
||||||
docker build -t $IMAGE_TAG .
|
echo "🔧 Building $IMAGE_LATEST"
|
||||||
|
docker build -t $IMAGE_LATEST .
|
||||||
|
|
||||||
echo "📤 Pushing $IMAGE_TAG"
|
echo "📤 Pushing $IMAGE_LATEST"
|
||||||
docker push $IMAGE_TAG
|
docker push $IMAGE_LATEST
|
||||||
|
|
||||||
|
# If this is a tag push, tag the image accordingly
|
||||||
|
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
|
||||||
|
GIT_TAG="${GITHUB_REF#refs/tags/}"
|
||||||
|
IMAGE_TAGGED="$REGISTRY/$USERNAME/$IMAGE_NAME:$GIT_TAG"
|
||||||
|
|
||||||
|
echo "🏷️ Also tagging as $IMAGE_TAGGED"
|
||||||
|
docker tag $IMAGE_LATEST $IMAGE_TAGGED
|
||||||
|
|
||||||
|
echo "📤 Pushing $IMAGE_TAGGED"
|
||||||
|
docker push $IMAGE_TAGGED
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user