Versioning and docker builds
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled

This commit is contained in:
Corban-Lee Jones 2024-12-06 09:44:38 +00:00
parent afef3ae674
commit 0e566d9042
6 changed files with 104 additions and 0 deletions

4
.bump2version.cfg Normal file
View File

@ -0,0 +1,4 @@
[bumpversion]
current_version = 0.0.0
commit = True
tag = True

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
.gitignore
.env
venv/
logs/
__pycache__/
*.pyc
.gitea/
.vscode/

View File

@ -0,0 +1,59 @@
name: Build and Push Docker Image
run-name: ${{ gitea.actor }} is building and pushing a Docker Image
on:
push:
branches:
- master
- staging
- dev
pull_request:
branches:
- master
- staging
- dev
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install bump2version
run: pip install bump2version
- name: Get current version from bump2version
id: version
run: echo "VERSION=$(bump2version --dry-run --list patch | grep current_version | sed -r s,"^.*=",,)" >> $GITHUB_ENV
- name: Set Docker tag based on branch
id: tag
run: |
# master branch uses specific version tagging, others use the branch name
if [[ "${{ gitea.ref_name }}" == "master" ]]; then
TAG="${{ env.VERSION }}"
else
TAG="${{ gitea.ref_name }}"
fi
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Build Docker image
run: |
docker build -t Spiffo:${{ env.TAG }} .
- name: Login to Docker registry
run: echo ${{ secrets.DOCKER_TOKEN }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Tag & Push Docker image
run: |
# Push the branch-specific or version-specific tag
docker tag Spiffo:${{ env.TAG }} xordk/Spiffo:${{ env.TAG }}
docker push xordk/Spiffo:${{ env.TAG }}
# If on master, push an additional "latest" tag
if [[ "${{ gitea.ref_name }}" == "master" ]]; then
docker tag Spiffo:${{ env.TAG }} xordk/Spiffo:latest
docker push xordk/Spiffo:latest
fi

16
CHANGELOG.md Normal file
View File

@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Fixed
### Changed
### Removed

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM python:3.12.5-slim-bullseye
# python related environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
# install python dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app/
CMD ["python", "bot.py"]

View File

@ -2,6 +2,7 @@ aiohappyeyeballs==2.4.4
aiohttp==3.11.9
aiosignal==1.3.1
attrs==24.2.0
bump2version==1.0.1
discord.py==2.4.0
frozenlist==1.5.0
idna==3.10