update CI/CD

This commit is contained in:
2025-10-25 15:54:35 +04:00
parent 76d4dbd105
commit 2b71a6d0e7
2 changed files with 189 additions and 87 deletions

99
.github/workflows/publish-docker.yaml vendored Normal file
View File

@@ -0,0 +1,99 @@
name: Publish Docker Images
on:
push:
branches:
- main
paths:
- 'cmd/*/version.go'
- 'cmd/feedgen/*/version.go'
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
api: ${{ steps.filter.outputs.api }}
consumer: ${{ steps.filter.outputs.consumer }}
feedgen-az: ${{ steps.filter.outputs.feedgen-az }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
api:
- 'cmd/api/version.go'
consumer:
- 'cmd/consumer/version.go'
feedgen-az:
- 'cmd/feedgen/az/version.go'
publish-api:
needs: detect-changes
if: needs.detect-changes.outputs.api == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.aykhans.me
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install Task
uses: arduino/setup-task@v2
- name: Build and publish API
run: task docker-publish-api
publish-consumer:
needs: detect-changes
if: needs.detect-changes.outputs.consumer == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.aykhans.me
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install Task
uses: arduino/setup-task@v2
- name: Build and publish Consumer
run: task docker-publish-consumer
publish-feedgen-az:
needs: detect-changes
if: needs.detect-changes.outputs.feedgen-az == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
uses: docker/login-action@v3
with:
registry: git.aykhans.me
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Install Task
uses: arduino/setup-task@v2
- name: Build and publish Feedgen AZ
run: task docker-publish-feedgen-az

View File

@@ -3,7 +3,7 @@
version: "3"
vars:
DOCKER_REGISTRY: "git.aykhans.me/bsky/"
DOCKER_REGISTRY: "git.aykhans.me"
tasks:
ftl:
@@ -51,7 +51,7 @@ tasks:
desc: Publish docker image for api service
vars:
GO_VERSION_FILE: ./cmd/api/version.go
IMAGE_NAME: feedgen-api
IMAGE_NAME: /bsky/feedgen-api
VERSION:
sh: grep -o 'const version = "[^"]*"' {{.GO_VERSION_FILE}} | grep -o '"[^"]*"' | tr -d '"'
VERSIONED_IMAGE: "{{.DOCKER_REGISTRY}}{{.IMAGE_NAME}}:{{.VERSION}}"
@@ -71,7 +71,7 @@ tasks:
desc: Publish docker image for consumer service
vars:
GO_VERSION_FILE: ./cmd/consumer/version.go
IMAGE_NAME: feedgen-consumer
IMAGE_NAME: /bsky/feedgen-consumer
VERSION:
sh: grep -o 'const version = "[^"]*"' {{.GO_VERSION_FILE}} | grep -o '"[^"]*"' | tr -d '"'
VERSIONED_IMAGE: "{{.DOCKER_REGISTRY}}{{.IMAGE_NAME}}:{{.VERSION}}"
@@ -87,7 +87,7 @@ tasks:
desc: Publish docker image for feedgen-az service
vars:
GO_VERSION_FILE: ./cmd/feedgen/az/version.go
IMAGE_NAME: feedgen-generator-az
IMAGE_NAME: /bsky/feedgen-generator-az
VERSION:
sh: grep -o 'const version = "[^"]*"' {{.GO_VERSION_FILE}} | grep -o '"[^"]*"' | tr -d '"'
VERSIONED_IMAGE: "{{.DOCKER_REGISTRY}}{{.IMAGE_NAME}}:{{.VERSION}}"
@@ -101,6 +101,9 @@ tasks:
docker-publish-manager:
desc: Publish docker image for manager service
vars:
GO_VERSION_FILE: ./cmd/manager/version.go
IMAGE_NAME: /bsky/feedgen-manager
cmds:
- docker build -t git.aykhans.me/bsky/feedgen-manager:latest -f ./cmd/manager/Dockerfile .
- docker push git.aykhans.me/bsky/feedgen-manager:latest
- docker build -t {{.DOCKER_REGISTRY}}{{.IMAGE_NAME}}:latest -f ./cmd/manager/Dockerfile .
- docker push {{.DOCKER_REGISTRY}}{{.IMAGE_NAME}}:latest