🤖 ci: move Docker push steps to separate job (closes #10)
This commit is contained in:
@@ -137,6 +137,57 @@ jobs:
|
|||||||
container:
|
container:
|
||||||
image: ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ needs.build-cache.outputs.deps_hash }}
|
image: ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}-build-cache:${{ needs.build-cache.outputs.deps_hash }}
|
||||||
|
|
||||||
|
docker-push:
|
||||||
|
name: Docker Push
|
||||||
|
needs: [build-cache, ci-pipeline]
|
||||||
|
runs-on: ubuntu-latest-ca
|
||||||
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'ci-bot' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/move-docker-job')"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Login to Gitea Container Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.CI_REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
run: |
|
||||||
|
source VERSION
|
||||||
|
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
||||||
|
|
||||||
|
# Use the template file with proper dependency hash replacement
|
||||||
|
DEPS_HASH="${{ needs.build-cache.outputs.deps_hash }}"
|
||||||
|
echo "Using dependency hash: $DEPS_HASH"
|
||||||
|
|
||||||
|
# Create Dockerfile.prod from template
|
||||||
|
sed "s/{{DEPS_HASH}}/$DEPS_HASH/g" docker/Dockerfile.prod.template > docker/Dockerfile.prod
|
||||||
|
|
||||||
|
TAGS="$IMAGE_VERSION latest ${{ github.sha }}"
|
||||||
|
echo "Building Docker image with tags: $TAGS"
|
||||||
|
|
||||||
|
# Build the production image
|
||||||
|
docker build -t dance-lessons-coach -f docker/Dockerfile.prod .
|
||||||
|
|
||||||
|
for TAG in $TAGS; do
|
||||||
|
IMAGE_NAME="${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$TAG"
|
||||||
|
echo "Tagging and pushing: $IMAGE_NAME"
|
||||||
|
docker tag dance-lessons-coach "$IMAGE_NAME"
|
||||||
|
docker push "$IMAGE_NAME"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Show published images
|
||||||
|
run: |
|
||||||
|
source VERSION
|
||||||
|
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
||||||
|
echo "📦 Published Docker images:"
|
||||||
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:$IMAGE_VERSION"
|
||||||
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:latest"
|
||||||
|
echo " - ${{ env.CI_REGISTRY }}/${{ env.GITEA_ORG }}/${{ env.GITEA_REPO }}:${{ github.sha }}"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:15
|
image: postgres:15
|
||||||
@@ -304,9 +355,19 @@ jobs:
|
|||||||
echo "ℹ️ No changes to push"
|
echo "ℹ️ No changes to push"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Docker build and push (main branch only)
|
|
||||||
|
|
||||||
|
docker-push:
|
||||||
|
name: Docker Push
|
||||||
|
needs: [build-cache, ci-pipeline]
|
||||||
|
runs-on: ubuntu-latest-ca
|
||||||
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'ci-bot' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/move-docker-job')"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
- name: Login to Gitea Container Registry
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.CI_REGISTRY }}
|
registry: ${{ env.CI_REGISTRY }}
|
||||||
@@ -314,7 +375,6 @@ jobs:
|
|||||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
password: ${{ secrets.PACKAGES_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
run: |
|
run: |
|
||||||
source VERSION
|
source VERSION
|
||||||
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
||||||
@@ -340,7 +400,6 @@ jobs:
|
|||||||
done
|
done
|
||||||
|
|
||||||
- name: Show published images
|
- name: Show published images
|
||||||
if: github.ref == 'refs/heads/main'
|
|
||||||
run: |
|
run: |
|
||||||
source VERSION
|
source VERSION
|
||||||
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
||||||
|
|||||||
1
issue_data.json
Normal file
1
issue_data.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"title": "Move Docker push steps to separate job", "body": "The current CI/CD workflow has Docker push steps in the second job that runs in a container. The container doesn't have Docker commands available. Need to move these steps to a new third job that runs on ubuntu-latest-ca without using a container."}
|
||||||
Reference in New Issue
Block a user