Add Docker publish pipeline

This commit is contained in:
2026-06-27 23:01:57 +02:00
parent 5b27852b97
commit ec4805f027
3 changed files with 129 additions and 1 deletions
+64
View File
@@ -0,0 +1,64 @@
name: publish
on:
push:
branches:
- "**"
workflow_dispatch:
env:
REGISTRY: gcr.forust.xyz
IMAGE_NAME: forust/telegram-scraper
jobs:
docker:
runs-on: [self-hosted, linux, arch, homelab]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read project version
id: version
shell: bash
run: |
version="$(python3 - <<'PY'
from pathlib import Path
import tomllib
print(tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"])
PY
)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Log in to registry
shell: bash
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \
-u "${{ secrets.REGISTRY_USERNAME }}" \
--password-stdin
- name: Build and push image
shell: bash
run: |
image="${REGISTRY}/${IMAGE_NAME}"
tags=("latest" "${{ steps.version.outputs.version }}")
case "${GITHUB_REF_NAME}" in
main)
tags+=("main" "prod")
;;
dev)
tags+=("dev")
;;
esac
build_args=()
for tag in "${tags[@]}"; do
build_args+=(-t "${image}:${tag}")
done
docker build "${build_args[@]}" .
for tag in "${tags[@]}"; do
docker push "${image}:${tag}"
done
+64
View File
@@ -0,0 +1,64 @@
name: publish
on:
push:
branches:
- "**"
workflow_dispatch:
env:
REGISTRY: gcr.forust.xyz
IMAGE_NAME: forust/telegram-scraper
jobs:
docker:
runs-on: [self-hosted, linux, arch, homelab]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Read project version
id: version
shell: bash
run: |
version="$(python3 - <<'PY'
from pathlib import Path
import tomllib
print(tomllib.loads(Path("pyproject.toml").read_text())["project"]["version"])
PY
)"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Log in to registry
shell: bash
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "${REGISTRY}" \
-u "${{ secrets.REGISTRY_USERNAME }}" \
--password-stdin
- name: Build and push image
shell: bash
run: |
image="${REGISTRY}/${IMAGE_NAME}"
tags=("latest" "${{ steps.version.outputs.version }}")
case "${GITHUB_REF_NAME}" in
main)
tags+=("main" "prod")
;;
dev)
tags+=("dev")
;;
esac
build_args=()
for tag in "${tags[@]}"; do
build_args+=(-t "${image}:${tag}")
done
docker build "${build_args[@]}" .
for tag in "${tags[@]}"; do
docker push "${image}:${tag}"
done
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "telegram-scraper"
version = "0.1.0"
version = "2.0.0"
description = "Telegram-scraper with webui"
readme = "README.md"
requires-python = ">=3.11"