Compare commits
68 Commits
fd39305966
...
feature/im
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2abaf6e6bf | ||
|
|
783b378673 | ||
|
|
73ccad3144 | ||
|
|
e215ba54e6 | ||
|
|
b73a52beb1 | ||
|
|
77799dded2 | ||
|
|
654f7bfec6 | ||
|
|
f35e45c38c | ||
|
|
fcfc773d87 | ||
|
|
74ff0f0673 | ||
|
|
c8cd562ca5 | ||
|
|
792eea4256 | ||
|
|
d5bf76a5af | ||
|
|
0a7f510648 | ||
|
|
7a658fc51e | ||
|
|
b3ffeec337 | ||
|
|
87753edb9a | ||
|
|
70a160e9f5 | ||
|
|
aab8c84f5c | ||
|
|
a89da7771a | ||
|
|
9cf825664a | ||
|
|
2823c55647 | ||
|
|
9636b9bcc9 | ||
|
|
c3b67fa626 | ||
|
|
ee6f30f283 | ||
|
|
2b54ec69ae | ||
|
|
9166be8ab0 | ||
|
|
c95fb00548 | ||
|
|
906028f3c8 | ||
|
|
8efa1c64d4 | ||
|
|
a20a7b31e9 | ||
|
|
ddddaf327d | ||
|
|
0ab4d13091 | ||
|
|
11bfa81c78 | ||
|
|
8d45979b18 | ||
|
|
5b3ccf5d1f | ||
|
|
ee1148ca9f | ||
|
|
9582106dc6 | ||
|
|
960770d73b | ||
|
|
8d36f66ea7 | ||
|
|
6707f4d93a | ||
|
|
0085aa690f | ||
|
|
b048a9d4a6 | ||
|
|
4c8e159236 | ||
|
|
0db1f6432c | ||
|
|
fb893cf056 | ||
|
|
27c46570df | ||
|
|
00aeee85a6 | ||
|
|
f7e5ddb0da | ||
|
|
96cdd6d0a4 | ||
|
|
1a30ce6b75 | ||
|
|
276d035df7 | ||
|
|
cb45cd0c5c | ||
|
|
2f97f60196 | ||
|
|
c27bb14060 | ||
|
|
fd88dadf21 | ||
|
|
2f79f0c4fe | ||
|
|
da4952aaa6 | ||
|
|
e4953aa769 | ||
|
|
0bf4036603 | ||
|
|
a0b9e5b692 | ||
|
|
0938ce1270 | ||
|
|
2c78aeeddd | ||
|
|
c56f1f701f | ||
|
|
0b523e75fd | ||
|
|
14170e3261 | ||
|
|
32b391d15d | ||
| 74b6092838 |
49
.gitea/actions/build/action.yml
Normal file
49
.gitea/actions/build/action.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
name: Build docker image
|
||||
description: 'builds docker image'
|
||||
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Docker image tag'
|
||||
required: true
|
||||
REGISTRY_ACCESS_TOKEN:
|
||||
description: 'Registry token to authenticate'
|
||||
required: true
|
||||
REGISTRY_USER:
|
||||
description: 'Registry user to authenticate'
|
||||
required: true
|
||||
|
||||
outputs:
|
||||
image_url:
|
||||
description: 'Full image URL that was built'
|
||||
value: ${{ steps.build.outputs.image_url }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Set up Docker Build
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ vars.INSTANCE_URL }}
|
||||
username: ${{ inputs.REGISTRY_USER }}
|
||||
password: ${{ inputs.REGISTRY_ACCESS_TOKEN }}
|
||||
|
||||
- name: Set repository variable
|
||||
shell: bash
|
||||
id: repo
|
||||
run: |
|
||||
REPOSITORY=$(echo "${{ gitea.repository }}" | tr '[:upper:]' '[:lower:]')
|
||||
echo "name=$REPOSITORY" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: '${{ vars.INSTANCE_URL }}/${{ steps.repo.outputs.name }}:${{ inputs.tag }}'
|
||||
|
||||
- name: Set output
|
||||
shell: bash
|
||||
run: |
|
||||
echo "image_url=${{ vars.INSTANCE_URL }}/${{ steps.repo.outputs.name }}:${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
||||
87
.gitea/actions/deploy/action.yml
Normal file
87
.gitea/actions/deploy/action.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
name: 'Docker Compose Deploy'
|
||||
description: 'Deploy application using Docker Compose'
|
||||
|
||||
inputs:
|
||||
compose_file:
|
||||
description: 'Path to docker-compose file'
|
||||
required: false
|
||||
default: 'docker-compose.yml'
|
||||
project_name:
|
||||
description: 'Docker Compose project name'
|
||||
required: true
|
||||
url:
|
||||
description: 'Url of the deployed application'
|
||||
required: true
|
||||
environment_file:
|
||||
description: 'Path to environment file'
|
||||
required: false
|
||||
default: '.env'
|
||||
image_url:
|
||||
description: 'Docker image tag to deploy'
|
||||
required: false
|
||||
default: 'latest'
|
||||
registry:
|
||||
description: 'Docker registry'
|
||||
required: false
|
||||
default: 'git.klemp.dev'
|
||||
deployment_key:
|
||||
description: 'SSH deployment private key'
|
||||
required: true
|
||||
ssh_port:
|
||||
description: 'SSH port'
|
||||
required: true
|
||||
ssh_host:
|
||||
description: 'SSH host'
|
||||
required: true
|
||||
ssh_user:
|
||||
description: 'SSH user'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Get branch name
|
||||
id: branch_name
|
||||
uses: ./.gitea/actions/getTagSafeRef
|
||||
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ inputs.deployment_key }}
|
||||
|
||||
- name: Add SSH host to known hosts
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -p ${{ inputs.ssh_port }} ${{ inputs.ssh_host }} >> ~/.ssh/known_hosts
|
||||
|
||||
cat > .env << EOF
|
||||
IMAGE_URL='${{ inputs.image_url }}'
|
||||
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
|
||||
|
||||
docker context rm deploy_target 2>/dev/null || true
|
||||
docker context create deploy_target --docker "host=ssh://${{ inputs.ssh_user }}@${{ inputs.ssh_host }}:${{ inputs.ssh_port }}"
|
||||
|
||||
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} down --remove-orphans || true
|
||||
|
||||
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} pull
|
||||
|
||||
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: ${{ inputs.url }}"
|
||||
echo "📦 Containers: $CONTAINERS"
|
||||
|
||||
echo "=== Deployment Status ==="
|
||||
DOCKER_CONTEXT=deploy_target docker compose -f docker-compose.yml -p ${{ steps.branch_name.outputs.branch_name }} ps
|
||||
echo "========================="
|
||||
52
.gitea/actions/getTagSafeRef/action.yml
Normal file
52
.gitea/actions/getTagSafeRef/action.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
name: 'Get Tag Safe Branch Name'
|
||||
description: 'Get a sanitized branch name that can be used as a Docker tag'
|
||||
|
||||
outputs:
|
||||
branch_name:
|
||||
description: 'Branch name that can be used as docker image tag'
|
||||
value: ${{ steps.get-branch.outputs.branch_name }}
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Get PR branch info via Gitea API
|
||||
if: github.event.issue.pull_request
|
||||
id: pr-info
|
||||
shell: bash
|
||||
run: |
|
||||
# Use Gitea's API endpoint
|
||||
PR_URL="${{ github.event.issue.pull_request.url }}"
|
||||
|
||||
# Extract PR info using curl (Gitea API is similar to GitHub)
|
||||
PR_INFO=$(curl -s -H "Authorization: token ${{ gitea.token }}" "${{ gitea.api_url }}/repos/${{ gitea.repository }}/pulls/${{ gitea.event.issue.number }}")
|
||||
|
||||
# Extract branch name from JSON response
|
||||
BRANCH_NAME=$(echo "$PR_INFO" | jq -r '.head.ref')
|
||||
|
||||
echo "pr_branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
|
||||
echo "Found PR branch: $BRANCH_NAME"
|
||||
|
||||
- name: Create tag safe branch name
|
||||
id: get-branch
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${{ github.event.issue.pull_request }}" != "" && "${{ github.event.issue.pull_request }}" != "null" ]]; then
|
||||
# This is a PR comment - use the branch we got from API
|
||||
BRANCH_NAME="${{ steps.pr-info.outputs.pr_branch }}"
|
||||
echo "Using PR branch: $BRANCH_NAME"
|
||||
elif [[ "${{ github.head_ref }}" != "" ]]; then
|
||||
# This is a PR workflow
|
||||
BRANCH_NAME="${{ github.head_ref }}"
|
||||
echo "Using head ref: $BRANCH_NAME"
|
||||
else
|
||||
# This is a push to main/other branch
|
||||
BRANCH_NAME="${{ github.ref_name }}"
|
||||
echo "Using ref name: $BRANCH_NAME"
|
||||
fi
|
||||
|
||||
# Clean the branch name for Docker tag compatibility
|
||||
CLEAN_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
echo "Original branch: $BRANCH_NAME"
|
||||
echo "Clean branch: $CLEAN_BRANCH"
|
||||
echo "branch_name=$CLEAN_BRANCH" >> $GITHUB_OUTPUT
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
branches: [main, develop]
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
@@ -29,112 +29,68 @@ jobs:
|
||||
- name: Build app
|
||||
run: bun --bun run build
|
||||
|
||||
type-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22.x'
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.3.4
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun ci
|
||||
|
||||
- name: Run type checking
|
||||
run: bun --bun run check
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: '22.x'
|
||||
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.3.4
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun ci
|
||||
|
||||
- name: Run linting
|
||||
run: bun --bun run lint:check
|
||||
|
||||
- name: Check formatting
|
||||
run: bun --bun run format:check
|
||||
|
||||
build-docker-image:
|
||||
format-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Build
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to registry
|
||||
uses: docker/login-action@v3
|
||||
- name: Install node
|
||||
uses: actions/setup-node@v6
|
||||
with:
|
||||
registry: ${{ vars.INSTANCE_URL }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
node-version: '22.x'
|
||||
|
||||
- name: Build and push image
|
||||
uses: docker/build-push-action@v6
|
||||
- name: Install bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
push: true
|
||||
tags: ${{ github.repository }}:${{ github.sha }}
|
||||
bun-version: 1.3.4
|
||||
|
||||
# type-check:
|
||||
# runs-on: ubuntu-latest
|
||||
# container:
|
||||
# image: oven/bun:alpine
|
||||
# needs: install-dependencies
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
- name: Install dependencies
|
||||
run: bun ci
|
||||
|
||||
# - name: Download node_modules artifact
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: node_modules
|
||||
# path: node_modules
|
||||
|
||||
# - name: Run type checking
|
||||
# run: bun run check
|
||||
|
||||
# lint:
|
||||
# runs-on: ubuntu-latest
|
||||
# container:
|
||||
# image: oven/bun:alpine
|
||||
# needs: install-dependencies
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: Download node_modules artifact
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: node_modules
|
||||
# path: node_modules
|
||||
|
||||
# - name: Run linting
|
||||
# run: bun run lint:check
|
||||
|
||||
# format-check:
|
||||
# runs-on: ubuntu-latest
|
||||
# container:
|
||||
# image: oven/bun:alpine
|
||||
# needs: install-dependencies
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: Download node_modules artifact
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: node_modules
|
||||
# path: node_modules
|
||||
|
||||
# - name: Check formatting
|
||||
# run: bun run format:check
|
||||
|
||||
# build:
|
||||
# runs-on: ubuntu-latest
|
||||
# container:
|
||||
# image: oven/bun:alpine
|
||||
# needs: install-dependencies
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: Download node_modules artifact
|
||||
# uses: actions/download-artifact@v3
|
||||
# with:
|
||||
# name: node_modules
|
||||
# path: node_modules
|
||||
|
||||
# - name: Build application
|
||||
# run: bun run build
|
||||
|
||||
# - name: Upload build artifacts
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: build-output
|
||||
# path: build/
|
||||
# retention-days: 7
|
||||
- name: Check formatting
|
||||
run: bun --bun run format:check
|
||||
|
||||
82
.gitea/workflows/commentDeploy.yml
Normal file
82
.gitea/workflows/commentDeploy.yml
Normal file
@@ -0,0 +1,82 @@
|
||||
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: 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: 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: 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 "========================="
|
||||
112
.gitea/workflows/deploy.yml
Normal file
112
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,112 @@
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get branch name
|
||||
id: branch_name
|
||||
uses: ./.gitea/actions/getTagSafeRef
|
||||
|
||||
- name: Determine image tag
|
||||
id: image_tag
|
||||
run: |
|
||||
if [[ ${{ github.ref }} == refs/tags/* ]]; then
|
||||
IMAGE_TAG=${{ github.ref_name }}
|
||||
ENVIRONMENT=production
|
||||
elif [[ ${{ github.ref }} == refs/heads/develop ]]; then
|
||||
IMAGE_TAG="develop"
|
||||
ENVIRONMENT=develop
|
||||
fi
|
||||
echo "tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
|
||||
echo "env=$ENVIRONMENT" >> $GITHUB_OUTPUT
|
||||
echo "Image tag will be: $IMAGE_TAG"
|
||||
echo "env will be: $ENVIRONMENT"
|
||||
|
||||
- name: Build and push image
|
||||
id: docker_build
|
||||
uses: ./.gitea/actions/build
|
||||
with:
|
||||
tag: ${{ steps.image_tag.outputs.tag }}
|
||||
REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||
REGISTRY_USER: ${{ gitea.actor }}
|
||||
|
||||
- name: Determine URL
|
||||
id: url
|
||||
run: |
|
||||
if [[ ${{ github.ref_type }} == "tag" ]]; then
|
||||
URL="phoenix.klemp.local"
|
||||
elif [[ ${{ github.ref_name }} == "develop" ]]; then
|
||||
URL="develop.phoenix.klemp.local"
|
||||
fi
|
||||
echo "url=$URL" >> $GITHUB_OUTPUT
|
||||
echo "URL will be: $URL"
|
||||
|
||||
- name: Setup SSH
|
||||
uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
||||
|
||||
- name: Add SSH host to known hosts
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -p ${{ vars.ssh_port }} ${{ vars.ssh_host }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Create environment file
|
||||
run: |
|
||||
cat > .env << EOF
|
||||
IMAGE_URL='${{ steps.docker_build.outputs.image_url }}'
|
||||
URL='${{ steps.url.outputs.url }}'
|
||||
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_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: 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 "========================="
|
||||
27
docker-compose.yml
Normal file
27
docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
networks:
|
||||
tolgee:
|
||||
name: tolgee
|
||||
external: true
|
||||
default:
|
||||
name: traefik-proxy
|
||||
external: true
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ${IMAGE_URL}
|
||||
container_name: ${PROJECT_NAME}-app
|
||||
networks:
|
||||
- tolgee
|
||||
environment:
|
||||
TOLGEE_API_URL: ${TOLGEE_API_URL}
|
||||
TOLGEE_API_KEY: ${TOLGEE_API_KEY}
|
||||
TRANSLATION_CACHE_TTL: ${TRANSLATION_CACHE_TTL}
|
||||
restart: unless-stopped
|
||||
labels:
|
||||
- traefik.enable=true
|
||||
- traefik.docker.network=traefik-proxy
|
||||
|
||||
- traefik.http.routers.${PROJECT_NAME}.entrypoints=http
|
||||
- traefik.http.routers.${PROJECT_NAME}.service=${PROJECT_NAME}
|
||||
- traefik.http.routers.${PROJECT_NAME}.rule=Host(`${URL}`)
|
||||
- traefik.http.services.${PROJECT_NAME}.loadbalancer.server.port=3000
|
||||
@@ -64,6 +64,7 @@ class LanguageService {
|
||||
|
||||
protected async fetchTranslations(languageCodes: string | string[]) {
|
||||
const url = new URL(`${env.TOLGEE_API_URL}/v2/projects/2/export`)
|
||||
console.log('Getting language data', url.toString())
|
||||
|
||||
url.searchParams.append('format', 'JSON')
|
||||
url.searchParams.append('zip', 'true')
|
||||
@@ -76,7 +77,6 @@ class LanguageService {
|
||||
if (!env.TOLGEE_API_KEY) {
|
||||
throw new Error('TOLGEE_API_KEY not set')
|
||||
}
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
"skipLibCheck": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler",
|
||||
},
|
||||
"moduleResolution": "bundler"
|
||||
}
|
||||
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
||||
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user