try using action
Some checks failed
CI / build-and-test (push) Has been cancelled

This commit is contained in:
Tobias Klemp
2026-01-02 20:07:20 +01:00
parent 87753edb9a
commit b3ffeec337
3 changed files with 64 additions and 98 deletions

View File

@@ -27,66 +27,61 @@ inputs:
deployment_key: deployment_key:
description: 'SSH deployment private key' description: 'SSH deployment private key'
required: true required: true
ssh_port:
description: 'SSH port'
required: true
ssh_host:
description: 'SSH host'
required: true
ssh_user:
description: 'SSH user'
required: true
runs: runs:
using: 'composite' using: 'composite'
steps: steps:
- uses: webfactory/ssh-agent@v0.9.1 - name: Get branch name
id: branch_name
uses: ./.gitea/actions/getTagSafeRef
- name: Setup SSH
uses: webfactory/ssh-agent@v0.9.1
with: with:
ssh-private-key: ${{ inputs.deployment_key }} ssh-private-key: ${{ inputs.deployment_key }}
- name: Create environment file - name: Add SSH host to known hosts
shell: bash shell: bash
run: | run: |
cat > ${{ inputs.environment_file }} << EOF mkdir -p ~/.ssh
IMAGE_URL=${{ inputs.image_url }} ssh-keyscan -p ${{ inputs.ssh_port }} ${{ inputs.ssh_host }} >> ~/.ssh/known_hosts
URL=${{ inputs.url }}
REGISTRY=${{ inputs.registry }} cat > .env << EOF
PROJECT_NAME=${{ inputs.project_name }} IMAGE_URL='${{ inputs.image_url }}'
COMPOSE_PROJECT_NAME=${{ inputs.project_name }} URL='${{ inputs.url }}'
REGISTRY=git.klemp.dev
PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
COMPOSE_PROJECT_NAME=${{ steps.branch_name.outputs.branch_name }}
EOF EOF
- name: Remove old Docker context docker context rm deploy_target 2>/dev/null || true
shell: bash docker context create deploy_target --docker "host=ssh://${{ inputs.ssh_user }}@${{ input.ssh_host }}:${{ input.ssh_port }}"
run: 'docker context rm deploy_target 2>/dev/null || true'
- name: Create Docker context DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} down --remove-orphans || true
shell: bash
run: 'docker context create deploy_target --docker "host=ssh://${{ vars.ssh_user }}@${{ vars.ssh_host }}:${{ vars.ssh_port }}"'
- name: Validate Docker context DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} pull
shell: bash
run: 'docker --context deploy_target info'
- name: Stop existing deployment DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} up -d
shell: bash
run: |
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} down --remove-orphans || true
- name: Pull latest images
shell: bash
run: |
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} pull
- name: Deploy with Docker Compose
id: deploy
shell: bash
run: |
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} up -d
echo "Waiting for services to start..." echo "Waiting for services to start..."
sleep 10 sleep 10
CONTAINERS=$(docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} ps --services | tr '\n' ',' | sed 's/,$//') 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 "containers=$CONTAINERS" >> $GITHUB_OUTPUT
echo "✅ Deployment completed successfully!" echo "✅ Deployment completed successfully!"
echo "🌐 URL: ${{ inputs.url }}" echo "🌐 URL: ${{ inputs.url }}"
echo "📦 Containers: $CONTAINERS" echo "📦 Containers: $CONTAINERS"
- name: Show deployment status
shell: bash
run: |
echo "=== Deployment Status ===" echo "=== Deployment Status ==="
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} ps DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} ps
echo "=========================" echo "========================="

View File

@@ -8,13 +8,13 @@ jobs:
startsWith(gitea.event.comment.body, '/deploy') startsWith(gitea.event.comment.body, '/deploy')
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get branch name - name: Get branch name
id: branch_name id: branch_name
uses: ./.gitea/actions/getTagSafeRef uses: ./.gitea/actions/getTagSafeRef
- name: Checkout
uses: actions/checkout@v4
# - name: Build and push image # - name: Build and push image
# id: docker_build # id: docker_build
# uses: ./.gitea/actions/build # uses: ./.gitea/actions/build
@@ -23,46 +23,21 @@ jobs:
# REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }} # REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
# REGISTRY_USER: ${{ gitea.actor }} # REGISTRY_USER: ${{ gitea.actor }}
# - name: Deploy application - name: Deploy application
# uses: ./.gitea/actions/deploy 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: with:
ssh-private-key: ${{ secrets.SSH_DEPLOYMENT_KEY }} project_name: ${{ steps.branch_name.outputs.branch_name }}
url: '${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local'
- name: Add SSH host to known hosts # image_url: ${{ steps.docker_bui ld.outputs.image_url }}
run: | image_url: 'git.klemp.dev/tech-reborn/phoenix:feature-branch-deployments'
mkdir -p ~/.ssh deployment_key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
ssh-keyscan -p ${{ vars.ssh_port }} ${{ vars.ssh_host }} >> ~/.ssh/known_hosts ssh_host: ${{ vars.ssh_host }}
ssh_port: ${{ vars.ssh_port }}
- name: Test SSH connection ssh_user: ${{ vars.ssh_user }}
run: |
# Test basic SSH connection
ssh -o StrictHostKeyChecking=no ${{ vars.ssh_user }}@${{ vars.ssh_host }} -p ${{ vars.ssh_port }} "echo 'SSH connection successful'"
- name: Test Docker via SSH
run: |
# Test Docker version through SSH
ssh -o StrictHostKeyChecking=no ${{ vars.ssh_user }}@${{ vars.ssh_host }} -p ${{ vars.ssh_port }} "docker --version"
# Test Docker info through SSH
ssh -o StrictHostKeyChecking=no ${{ vars.ssh_user }}@${{ vars.ssh_host }} -p ${{ vars.ssh_port }} "docker info --format '{{.ServerVersion}}'"
- name: Create environment file - name: Create environment file
run: | run: |
cat > .env << EOF cat > .env << 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 }}
TOLGEE_API_URL=${{ vars.TOLGEE_API_URL }} TOLGEE_API_URL=${{ vars.TOLGEE_API_URL }}
TOLGEE_API_KEY=${{ secrets.TOLGEE_API_KEY }} TOLGEE_API_KEY=${{ secrets.TOLGEE_API_KEY }}
TRANSLATION_CACHE_TTL=${{ vars.TRANSLATION_CACHE_TTL }} TRANSLATION_CACHE_TTL=${{ vars.TRANSLATION_CACHE_TTL }}

View File

@@ -77,7 +77,6 @@ class LanguageService {
if (!env.TOLGEE_API_KEY) { if (!env.TOLGEE_API_KEY) {
throw new Error('TOLGEE_API_KEY not set') throw new Error('TOLGEE_API_KEY not set')
} }
try {
const response = await fetch(url, { const response = await fetch(url, {
method: 'GET', method: 'GET',
headers: { headers: {
@@ -101,9 +100,6 @@ class LanguageService {
} }
return translations return translations
} catch (e) {
console.error('Failed to get language data', e, JSON.stringify(e))
}
} }
} }