Refactor CI workflow to update version.py with build timestamp in Dockerfile

This commit is contained in:
SergeantPanda 2025-04-27 18:53:39 -05:00
parent a81daaea44
commit 07edf270fb
2 changed files with 13 additions and 11 deletions

View file

@ -50,15 +50,6 @@ jobs:
TIMESTAMP=$(date -u +'%Y%m%d%H%M%S')
echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT
# Update the timestamp in version.py
echo "Updating timestamp to ${TIMESTAMP} in version.py"
sed -i "s|__timestamp__ = None.*|__timestamp__ = '${TIMESTAMP}' # Set during CI/CD build process|" version.py
cat version.py # Verify the file was updated correctly
# Make the version.py change part of the Docker build context
git add version.py
git commit -m "Update build timestamp [skip ci]" || echo "No changes to commit"
- name: Extract version info
id: version
run: |
@ -111,4 +102,5 @@ jobs:
build-args: |
BRANCH=${{ github.ref_name }}
REPO_URL=https://github.com/${{ github.repository }}
TIMESTAMP=${{ steps.timestamp.outputs.timestamp }}
file: ./docker/Dockerfile

View file

@ -5,6 +5,8 @@ ARG BRANCH=main
# This will be overridden by the GitHub Actions workflow
# when building the Docker image for production.
ARG REPO_URL=https://github.com/Dispatcharr/Dispatcharr
# Add timestamp argument
ARG TIMESTAMP
ENV PATH="/dispatcharrpy/bin:$PATH" \
VIRTUAL_ENV=/dispatcharrpy \
@ -26,8 +28,16 @@ RUN apt-get update && \
virtualenv /dispatcharrpy && \
git clone -b ${BRANCH} ${REPO_URL} /app && \
cd /app && \
rm -rf .git && \
cd /app && \
rm -rf .git
# Update version.py with build timestamp if provided
RUN if [ -n "$TIMESTAMP" ]; then \
echo "Updating timestamp to ${TIMESTAMP} in version.py" && \
sed -i "s|__timestamp__ = None.*|__timestamp__ = '${TIMESTAMP}' # Set during CI/CD build process|" /app/version.py && \
cat /app/version.py; \
fi
RUN cd /app && \
pip install --no-cache-dir -r requirements.txt
# Use a dedicated Node.js stage for frontend building