mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-10 05:30:08 -06:00
Update docker-publish.yml
This commit is contained in:
29
.github/workflows/docker-publish.yml
vendored
29
.github/workflows/docker-publish.yml
vendored
@@ -72,13 +72,30 @@ jobs:
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
# Build the image using our created Dockerfile
|
||||
docker build -f Dockerfile.simple -t ghcr.io/drytrix/timetracker:main .
|
||||
IMAGE_ID=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
# Push if not a PR
|
||||
if [ "${{ github.event_name }}" != "pull_request" ]; then
|
||||
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
|
||||
docker push ghcr.io/drytrix/timetracker:main
|
||||
# Strip "refs/tags/" prefix if it's a tag event
|
||||
VERSION=${GITHUB_REF#refs/tags/}
|
||||
|
||||
# Fallback: if it's not a tag, use branch name
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=${GITHUB_REF#refs/heads/}
|
||||
fi
|
||||
|
||||
echo "Image ID: $IMAGE_ID"
|
||||
echo "Version: $VERSION"
|
||||
|
||||
# Build the Docker image
|
||||
docker build -f Dockerfile.simple -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
|
||||
|
||||
Reference in New Issue
Block a user