♻️ refactor: split Docker push into separate workflow file
This commit is contained in:
@@ -6,31 +6,7 @@
|
|||||||
name: CI/CD Pipeline
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Workflow dispatch with optional parameters for flexible testing
|
workflow_dispatch: {}
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
skip_ci:
|
|
||||||
description: 'Skip CI pipeline and go straight to Docker push'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
docker_only:
|
|
||||||
description: 'Run only Docker push steps (requires skip_ci=true)'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
skip_ci:
|
|
||||||
description: 'Skip CI pipeline and go straight to Docker push'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
docker_only:
|
|
||||||
description: 'Run only Docker push steps (requires skip_ci=true)'
|
|
||||||
required: false
|
|
||||||
type: boolean
|
|
||||||
default: false
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
@@ -331,54 +307,26 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
docker-push:
|
|
||||||
name: Docker Push
|
# Trigger Docker push workflow on main branch
|
||||||
|
trigger-docker-push:
|
||||||
|
name: Trigger Docker Push
|
||||||
needs: [build-cache, ci-pipeline]
|
needs: [build-cache, ci-pipeline]
|
||||||
runs-on: ubuntu-latest-ca
|
runs-on: ubuntu-latest-ca
|
||||||
# Run conditions: standard checks + main branch + feature branch + docker_only override
|
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'ci-bot' && github.ref == 'refs/heads/main'"
|
||||||
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' || github.event.inputs.docker_only == 'true')"
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Trigger Docker Push Workflow
|
||||||
uses: actions/checkout@v4
|
uses: actions/github-script@v6
|
||||||
|
|
||||||
- name: Login to Gitea Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.CI_REGISTRY }}
|
script: |
|
||||||
username: ${{ github.actor }}
|
await github.rest.actions.createWorkflowDispatch({
|
||||||
password: ${{ secrets.PACKAGES_TOKEN }}
|
owner: 'arcodange',
|
||||||
|
repo: 'dance-lessons-coach',
|
||||||
- name: Build and push Docker image
|
workflow_id: 'docker-push.yaml',
|
||||||
run: |
|
ref: 'main',
|
||||||
source VERSION
|
inputs: {
|
||||||
IMAGE_VERSION="$MAJOR.$MINOR.$PATCH${PRERELEASE:+-$PRERELEASE}"
|
deps_hash: '${{ needs.build-cache.outputs.deps_hash }}',
|
||||||
|
ref: 'main'
|
||||||
# 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 }}"
|
|
||||||
|
|||||||
80
.gitea/workflows/docker-push.yaml
Normal file
80
.gitea/workflows/docker-push.yaml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
---
|
||||||
|
# dance-lessons-coach Docker Push Workflow
|
||||||
|
# Separate workflow for Docker image building and pushing
|
||||||
|
# Can be triggered manually or by CI/CD workflow
|
||||||
|
|
||||||
|
name: Docker Push
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Manual trigger only - no automatic triggers
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
deps_hash:
|
||||||
|
description: 'Dependency hash from build-cache job'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
ref:
|
||||||
|
description: 'Git reference (branch/tag)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
env:
|
||||||
|
GITEA_INTERNAL: "https://gitea.arcodange.lab/"
|
||||||
|
GITEA_EXTERNAL: "https://gitea.arcodange.fr/"
|
||||||
|
GITEA_ORG: "arcodange"
|
||||||
|
GITEA_REPO: "dance-lessons-coach"
|
||||||
|
CI_REGISTRY: "gitea.arcodange.lab"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
docker-push:
|
||||||
|
name: Docker Push
|
||||||
|
runs-on: ubuntu-latest-ca
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.ref || github.ref }}
|
||||||
|
|
||||||
|
- 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 provided dependency hash
|
||||||
|
DEPS_HASH="${{ github.event.inputs.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 }}"
|
||||||
Reference in New Issue
Block a user