fixes
Some checks failed
CI / build-and-test (push) Failing after 4m31s
Deploy / build-and-deploy (push) Failing after 17m50s

This commit is contained in:
Tobias Klemp
2026-01-03 17:15:57 +01:00
parent 792eea4256
commit c8cd562ca5

View File

@@ -8,21 +8,28 @@ on:
- '*' - '*'
jobs: jobs:
build: build-and-deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Get branch name
id: branch_name
uses: ./.gitea/actions/getTagSafeRef
- name: Determine image tag - name: Determine image tag
id: image_tag id: image_tag
run: | run: |
if [[ ${{ github.ref }} == refs/tags/* ]]; then if [[ ${{ github.ref }} == refs/tags/* ]]; then
IMAGE_TAG=${{ github.ref_name }} IMAGE_TAG=${{ github.ref_name }}
ENVIRONMENT=production
elif [[ ${{ github.ref }} == refs/heads/develop ]]; then elif [[ ${{ github.ref }} == refs/heads/develop ]]; then
IMAGE_TAG="develop" IMAGE_TAG="develop"
ENVIRONMENT=develop
fi fi
echo "tag=$IMAGE_TAG" >> $GITHUB_OUTPUT echo "tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "env=$ENVIRONMENT" >> $GITHUB_OUTPUT
echo "Image tag will be: $IMAGE_TAG" echo "Image tag will be: $IMAGE_TAG"
- name: Build and push image - name: Build and push image
@@ -33,14 +40,6 @@ jobs:
REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }} REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
REGISTRY_USER: ${{ gitea.actor }} REGISTRY_USER: ${{ gitea.actor }}
- 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: Determine URL - name: Determine URL
id: url id: url
run: | run: |
@@ -52,13 +51,53 @@ jobs:
echo "url=$URL" >> $GITHUB_OUTPUT echo "url=$URL" >> $GITHUB_OUTPUT
echo "URL will be: $URL" echo "URL will be: $URL"
- name: Deploy application - name: Create environment file
uses: ./.gitea/actions/deploy run: |
with: cat > .env << EOF
project_name: ${{ steps.branch_name.outputs.branch_name }} IMAGE_URL='${{ steps.docker_build.outputs.image_url }}'
url: '${{ steps.url.outputs.url }}' URL='${{ steps.url.outputs.url }}'
image_url: ${{ steps.docker_build.outputs.image_url }} REGISTRY=git.klemp.dev
deployment_key: ${{ secrets.SSH_DEPLOYMENT_KEY }} PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
ssh_host: ${{ vars.ssh_host }} COMPOSE_PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
ssh_port: ${{ vars.ssh_port }} TOLGEE_API_URL=${{ vars.TOLGEE_API_URL }}
ssh_user: ${{ vars.ssh_user }} 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.image_tag.outputs.env }} down --remove-orphans || true
- name: Pull latest images
run: |
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.image_tag.outputs.env }} pull
- name: Deploy with Docker Compose
id: deploy
run: |
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.image_tag.outputs.env }} up -d
echo "Waiting for services to start..."
sleep 10
CONTAINERS=$(DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.image_tag.outputs.env }} ps --services | tr '\n' ',' | sed 's/,$//')
echo "containers=$CONTAINERS" >> $GITHUB_OUTPUT
echo "✅ Deployment completed successfully!"
echo "🌐 URL: ${{ steps.url.outputs.url }}"
echo "📦 Containers: $CONTAINERS"
- name: Show deployment status
run: |
echo "=== Deployment Status ==="
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.image_tag.outputs.env }} ps
echo "========================="