Updated For Two versions

This commit is contained in:
Dries Peeters
2025-08-27 14:37:18 +02:00
parent 2aaeca919e
commit db628a48b4
8 changed files with 455 additions and 100 deletions

View File

@@ -0,0 +1,96 @@
name: Build and Publish TimeTracker Docker Image
on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]
release:
types: [ published ]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: drytrix/timetracker
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- name: amd64
platform: linux/amd64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check files and create combined Dockerfile
run: |
echo "--- Checking available files ---"
pwd
ls -la
echo "--- Checking if requirements.txt exists ---"
if [ -f requirements.txt ]; then
echo "requirements.txt found:"
cat requirements.txt
else
echo "requirements.txt NOT found!"
echo "Available .txt files:"
find . -name "*.txt" -type f
fi
echo "--- Creating combined Dockerfile ---"
cp Dockerfile Dockerfile.final
echo "Combined Dockerfile created successfully"
- name: Build and push Docker image
run: |
IMAGE_ID=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Extract version from ref
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ "${GITHUB_REF}" == refs/heads/* ]]; then
VERSION=${GITHUB_REF#refs/heads/}
else
VERSION=unknown
fi
# Replace any slashes with dashes (for feature branches etc.)
VERSION=${VERSION//\//-}
echo "Image ID: $IMAGE_ID"
echo "Version: $VERSION"
# Build the Docker image
docker build -f Dockerfile.final -t $IMAGE_ID:$VERSION .
# Always push versioned tag on releases/tags
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo ${{ secrets.GITHUB_TOKEN }} | docker login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
docker push $IMAGE_ID:$VERSION
# If this is a release, also push as latest
if [ "${{ github.event_name }}" == "release" ]; then
docker tag $IMAGE_ID:$VERSION $IMAGE_ID:latest
docker push $IMAGE_ID:latest
fi
fi

View File

@@ -12,7 +12,7 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: drytrix/timetracker
IMAGE_NAME: drytrix/timetracker-internalDB
jobs:
build: