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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ignore everything
**

# Except what we need
!bot
!pyproject.toml
!uv.lock
28 changes: 8 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
name: Build and deploy a Docker image

on:
workflow_run:
workflows: ["Linting"]
branches:
- master
types:
- completed

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

workflow_call:
inputs:
sha-tag:
description: "A short-form SHA tag for the commit that triggered this workflow"
required: true
type: string

jobs:
build:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push'
name: Build & Push to GHCR
runs-on: ubuntu-latest
steps:
- name: Create a short SHA tag
id: sha_tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "::set-output name=tag::$tag"

- name: Checkout code
uses: actions/checkout@v6

Expand All @@ -43,11 +31,11 @@ jobs:
with:
context: .
file: Dockerfile
push: true
push: ${{ github.ref == 'refs/heads/master' }}
cache-from: type=registry,ref=ghcr.io/fisher60/friendo-bot:latest
cache-to: type=inline
tags: |
ghcr.io/fisher60/friendo-bot:latest
ghcr.io/fisher60/friendo-bot:${{ steps.sha_tag.outputs.tag }}
ghcr.io/fisher60/friendo-bot:${{ inputs.sha-tag }}
build-args: |
git_sha=${{ github.sha }}
10 changes: 1 addition & 9 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
name: Linting

on:
push:
branches:
- master
- develop
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
workflow_call:

jobs:
lint:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
generate-sha-tag:
runs-on: ubuntu-latest
outputs:
sha-tag: ${{ steps.sha-tag.outputs.sha-tag }}
steps:
- name: Create short SHA to be used as a container tag
id: sha-tag
run: |
tag=$(cut -c 1-7 <<< $GITHUB_SHA)
echo "sha-tag=$tag" >> $GITHUB_OUTPUT

lint:
uses: ./.github/workflows/linting.yml

build-deploy:
uses: ./.github/workflows/build.yml
needs:
- lint
- generate-sha-tag
with:
sha-tag: ${{ needs.generate-sha-tag.outputs.sha-tag }}
secrets: inherit
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

# Copy the source code in last to optimize rebuilding the image
WORKDIR /app
COPY bot .
COPY . .

Check warning on line 36 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-deploy / Build & Push to GHCR

Attempting to Copy file that is excluded by .dockerignore

CopyIgnoredFile: Attempting to Copy file "." that is excluded by .dockerignore More info: https://docs.docker.com/go/dockerfile/rule/copy-ignored-file/

ENTRYPOINT ["python", "-m"]
CMD ["bot"]
7 changes: 6 additions & 1 deletion bot/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import tomllib
from os import environ
from pathlib import Path

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -34,7 +36,10 @@

log.info("Using %s for backend...", FRIENDO_API_URL)

VERSION = "1.2"
with Path("pyproject.toml").open("rb") as f:
pyproject = tomllib.load(f)

VERSION = pyproject["project"]["version"]

GITHUB_REPO = "https://github.com/fisher60/friendo-bot"

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
license = {text = "MIT"}
requires-python = "~=3.14.0"
name = "friendo-bot"
version = "0.0.1"
version = "1.2"
dependencies = [
"aiodns~=4.0.0",
"aiofiles~=25.1.0",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

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