Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.13
rev: v0.16.4
hooks:
- id: ruff
name: ruff-lint
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and publish Docker images

# Publishes the tpot-payload-server image to the
# GitHub Container Registry (GHCR) under ghcr.io/greedybear-project.

on:
push:
branches:
- main
- develop
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
workflow_call:
inputs:
ref:
description: Git ref to build. Defaults to the triggering ref.
type: string
required: false
version:
description: Semver version to tag the image with, e.g. 1.2.3.
type: string
required: false

# cancel superseded runs for the same ref
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
GHCR_NAMESPACE: ghcr.io/greedybear-project

jobs:
build-and-push:
name: Build and push ${{ matrix.image }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- image: tpot-payload-server
dockerfile: docker/Dockerfile
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
ref: ${{ inputs.ref || github.ref }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract image metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.GHCR_NAMESPACE }}/${{ matrix.image }}
# main branch -> prod
# develop branch -> stag
# X.Y.Z git tag -> X.Y.Z
# release.yml call -> X.Y.Z (from the version input)
tags: |
type=raw,value=prod,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=stag,enable=${{ github.ref == 'refs/heads/develop' }}
type=semver,pattern={{version}}
type=raw,value=${{ inputs.version }},enable=${{ inputs.version != '' }}
flavor: |
latest=false

- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.image }}
cache-to: type=gha,mode=max,scope=${{ matrix.image }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
release:
name: Create release and tag
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
match: ${{ steps.check-tag.outputs.match }}
version: ${{ steps.check-tag.outputs.version }}
if: >
github.event.pull_request.merged == true &&
github.base_ref == 'main'
Expand All @@ -28,6 +33,7 @@ jobs:
run: |
if [[ "${{ github.event.pull_request.title }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "match=true" >> $GITHUB_OUTPUT
echo "version=${{ github.event.pull_request.title }}" >> $GITHUB_OUTPUT
echo "PR title matches semver: ${{ github.event.pull_request.title }}"
else
echo "match=false" >> $GITHUB_OUTPUT
Expand All @@ -45,3 +51,15 @@ jobs:
prerelease: false
target_commitish: ${{ github.base_ref }}
append_body: true

publish-image:
name: Publish Docker image
needs: release
if: needs.release.outputs.match == 'true'
permissions:
contents: read
packages: write
uses: ./.github/workflows/docker_publish.yml
with:
ref: ${{ needs.release.outputs.version }}
version: ${{ needs.release.outputs.version }}
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "tpot-payload-server"
version = "0.1.0"
version = "0.2.0"
description = "Payload integration project for T-Pot and GreedyBear"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
"fastapi==0.141.1",
"python-magic==0.4.27",
"uvicorn==0.52.1",
"uvicorn==0.52.4",
]

[dependency-groups]
Expand All @@ -16,8 +16,8 @@ test = [
"httpx==0.28.1",
]
lint = [
"ruff==0.15.20",
"pre-commit==4.6.1",
"ruff==0.16.5",
"pre-commit==4.6.2",
]

[tool.ruff]
Expand Down Expand Up @@ -50,6 +50,7 @@ ignore = [
"ISC001", # Conflicts with formatter
"D100", # Missing docstring in public module
"D104", # Missing docstring in public package
"CPY001", # Missing copyright notice at top of file
]

[tool.ruff.lint.pydocstyle]
Expand Down
62 changes: 31 additions & 31 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading