83 lines
3.2 KiB
YAML
83 lines
3.2 KiB
YAML
name: ChatOps Deploy
|
|
on: issue_comment
|
|
|
|
jobs:
|
|
FeatureDeployment:
|
|
if: |
|
|
gitea.event.issue.pull_request &&
|
|
startsWith(gitea.event.comment.body, '/deploy')
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get branch name
|
|
id: branch_name
|
|
uses: ./.gitea/actions/getTagSafeRef
|
|
|
|
# - name: Build and push image
|
|
# id: docker_build
|
|
# uses: ./.gitea/actions/build
|
|
# with:
|
|
# tag: ${{ steps.branch_name.outputs.branch_name }}
|
|
# REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
|
# REGISTRY_USER: ${{ gitea.actor }}
|
|
|
|
- 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_bui ld.outputs.image_url }}
|
|
image_url: 'git.klemp.dev/tech-reborn/phoenix:feature-branch-deployments'
|
|
deployment_key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
|
ssh_host: ${{ vars.ssh_host }}
|
|
ssh_port: ${{ vars.ssh_port }}
|
|
ssh_user: ${{ vars.ssh_user }}
|
|
|
|
- name: Create environment file
|
|
run: |
|
|
cat > .env << EOF
|
|
TOLGEE_API_URL=${{ vars.TOLGEE_API_URL }}
|
|
TOLGEE_API_KEY=${{ secrets.TOLGEE_API_KEY }}
|
|
TRANSLATION_CACHE_TTL=${{ vars.TRANSLATION_CACHE_TTL }}
|
|
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_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} down --remove-orphans || true
|
|
|
|
- name: Pull latest images
|
|
run: |
|
|
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} pull
|
|
|
|
- name: Deploy with Docker Compose
|
|
id: deploy
|
|
run: |
|
|
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} up -d
|
|
|
|
echo "Waiting for services to start..."
|
|
sleep 10
|
|
|
|
CONTAINERS=$(DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} ps --services | tr '\n' ',' | sed 's/,$//')
|
|
echo "containers=$CONTAINERS" >> $GITHUB_OUTPUT
|
|
|
|
echo "✅ Deployment completed successfully!"
|
|
echo "🌐 URL: ${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local"
|
|
echo "📦 Containers: $CONTAINERS"
|
|
|
|
- name: Show deployment status
|
|
run: |
|
|
echo "=== Deployment Status ==="
|
|
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} ps
|
|
echo "========================="
|