@@ -23,11 +23,64 @@ jobs:
|
||||
# REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
# REGISTRY_USER: ${{ gitea.actor }}
|
||||
|
||||
- name: Deploy application
|
||||
uses: ./.gitea/actions/deploy
|
||||
# - name: Deploy application
|
||||
# uses: ./.gitea/actions/deploy
|
||||
# with:
|
||||
# project_name: ${{ steps.branch_name.outputs.branch_name }}
|
||||
# url: '${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local'
|
||||
# # image_url: ${{ steps.docker_build.outputs.image_url }}
|
||||
# image_url: 'git.klemp.dev/tech-reborn/phoenix:feature-branch-deployments'
|
||||
# deployment_key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
||||
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
project_name: ${{ steps.branch_name.outputs.branch_name }}
|
||||
url: '${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local'
|
||||
# image_url: ${{ steps.docker_build.outputs.image_url }}
|
||||
image_url: 'git.klemp.dev/tech-reborn/phoenix:feature-branch-deployments'
|
||||
deployment_key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
||||
ssh-private-key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
||||
|
||||
- name: Create environment file
|
||||
run: |
|
||||
cat > ${{ inputs.environment_file }} << EOF
|
||||
IMAGE_URL='git.klemp.dev/tech-reborn/phoenix:feature-branch-deployments'
|
||||
URL='${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local'
|
||||
REGISTRY=git.klemp.dev
|
||||
PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
|
||||
COMPOSE_PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
|
||||
EOF
|
||||
|
||||
- name: Remove old Docker context
|
||||
run: 'docker context rm deploy_target 2>/dev/null || true'
|
||||
|
||||
- name: Create Docker context
|
||||
run: 'docker context create deploy_target --docker "host=ssh://${{ vars.ssh_user }}@${{ vars.ssh_host }}:${{ vars.ssh_port }}"'
|
||||
|
||||
- name: Validate Docker context
|
||||
run: 'docker --context deploy_target info'
|
||||
|
||||
- name: Stop existing deployment
|
||||
run: |
|
||||
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} down --remove-orphans || true
|
||||
|
||||
- name: Pull latest images
|
||||
run: |
|
||||
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} pull
|
||||
|
||||
- name: Deploy with Docker Compose
|
||||
id: deploy
|
||||
run: |
|
||||
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} up -d
|
||||
|
||||
echo "Waiting for services to start..."
|
||||
sleep 10
|
||||
|
||||
CONTAINERS=$(docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} ps --services | tr '\n' ',' | sed 's/,$//')
|
||||
echo "containers=$CONTAINERS" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "✅ Deployment completed successfully!"
|
||||
echo "🌐 URL: ${{ inputs.url }}"
|
||||
echo "📦 Containers: $CONTAINERS"
|
||||
|
||||
- name: Show deployment status
|
||||
run: |
|
||||
echo "=== Deployment Status ==="
|
||||
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} ps
|
||||
echo "========================="
|
||||
|
||||
Reference in New Issue
Block a user