Compare commits
46 Commits
main
...
2045c292c1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2045c292c1 | ||
|
|
679972a604 | ||
|
|
735316a24b | ||
|
|
3cc5a09f3d | ||
|
|
e6eb9ab5da | ||
|
|
fbd2cf9dfa | ||
|
|
d57bccde00 | ||
|
|
405a3b8c05 | ||
|
|
0f398e1683 | ||
|
|
a7f016c6bf | ||
|
|
1472b7be45 | ||
|
|
1d81240104 | ||
|
|
06f304f9cb | ||
|
|
841024e9f3 | ||
|
|
4b4b8826e6 | ||
|
|
5aa06f0915 | ||
|
|
f5d0689359 | ||
|
|
2476e7ab12 | ||
|
|
1ac8717fec | ||
|
|
9f66da7904 | ||
|
|
dbe95b9352 | ||
|
|
66651f64f8 | ||
|
|
380ad293e7 | ||
|
|
b1ab2c02b8 | ||
|
|
6581cff44f | ||
|
|
e1f1e867d6 | ||
|
|
b1fe405434 | ||
|
|
cd091ab603 | ||
|
|
a8ca5b37f8 | ||
|
|
b6f56ae0fc | ||
|
|
5d2db330af | ||
|
|
3bd9cb6c2b | ||
|
|
a0b0d9e2e8 | ||
|
|
12b77193d0 | ||
|
|
ecf17af90a | ||
|
|
606d0842a1 | ||
|
|
778f696074 | ||
|
|
b5e410d7c6 | ||
|
|
58fb9d7656 | ||
|
|
5af0df8aed | ||
|
|
c1e9399954 | ||
|
|
cce1dfff33 | ||
|
|
c49cd85a09 | ||
|
|
45b7121e60 | ||
|
|
459c74822b | ||
|
|
2806575233 |
@@ -1,49 +0,0 @@
|
|||||||
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
|
|
||||||
35
.gitea/actions/buildDockerImage.yml
Normal file
35
.gitea/actions/buildDockerImage.yml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
name: Build docker image
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Docker image tag'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
image_url:
|
||||||
|
description: 'Full image URL that was built'
|
||||||
|
value: ${{ steps.build.outputs.image_url }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
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: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
push: true
|
||||||
|
tags: ${{ vars.INSTANCE_URL }}/tech-reborn/phoenix:${{ inputs.tag }}
|
||||||
|
|
||||||
|
- name: Set output
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "image_url=${{ vars.INSTANCE_URL }}/tech-reborn/phoenix:${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
||||||
93
.gitea/actions/deploy.yml
Normal file
93
.gitea/actions/deploy.yml
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
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'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- uses: webfactory/ssh-agent@v0.9.1
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SSH_DEPLOYMENT_KEY }}
|
||||||
|
|
||||||
|
- name: Create environment file
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cat > ${{ inputs.environment_file }} << EOF
|
||||||
|
IMAGE_URL=${{ inputs.image_url }}
|
||||||
|
URL=${{ inputs.url }}
|
||||||
|
REGISTRY=${{ inputs.registry }}
|
||||||
|
PROJECT_NAME=${{ inputs.project_name }}
|
||||||
|
COMPOSE_PROJECT_NAME=${{ inputs.project_name }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Create Docker context
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# Remove existing context if it exists
|
||||||
|
docker context rm deploy_target 2>/dev/null || true
|
||||||
|
|
||||||
|
# Create new Docker context
|
||||||
|
docker context create deploy_target \
|
||||||
|
--docker "host=ssh://${{ vars.ssh_user }}@${{ vars.ssh_host }}:${{ vars.ssh_port }}"
|
||||||
|
|
||||||
|
# Verify context works
|
||||||
|
docker --context deploy_target info
|
||||||
|
|
||||||
|
- name: Stop existing deployment
|
||||||
|
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: |
|
||||||
|
# Start services
|
||||||
|
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} up -d
|
||||||
|
|
||||||
|
# Wait for services to be healthy
|
||||||
|
echo "Waiting for services to start..."
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# Get container names
|
||||||
|
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
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "=== Deployment Status ==="
|
||||||
|
docker-compose --context deploy_target -f ${{ inputs.compose_file }} -p ${{ inputs.project_name }} ps
|
||||||
|
echo "========================="
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
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 "========================="
|
|
||||||
20
.gitea/actions/getTagSafeRef.yml
Normal file
20
.gitea/actions/getTagSafeRef.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Build docker image
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
branch_name:
|
||||||
|
description: 'Branch name that can be used as docker image tag'
|
||||||
|
value: ${{ steps.build.outputs.branch_name }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_docker:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Create tag name
|
||||||
|
run: |
|
||||||
|
BRANCH_NAME="${{ github.ref }}"
|
||||||
|
CLEAN_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g' | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
- name: Set output
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "branch_name=$CLEAN_BRANCH" >> $GITHUB_OUTPUT
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -2,81 +2,30 @@ name: ChatOps Deploy
|
|||||||
on: issue_comment
|
on: issue_comment
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
FeatureDeployment:
|
deploy:
|
||||||
if: |
|
# if: |
|
||||||
gitea.event.issue.pull_request &&
|
# github.event.issue.pull_request &&
|
||||||
startsWith(gitea.event.comment.body, '/deploy')
|
# startsWith(github.event.comment.body, '/deploy') &&
|
||||||
|
# (github.event.comment.author_association == 'OWNER' ||
|
||||||
|
# github.event.comment.author_association == 'MEMBER')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Get tag safe branch name
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Get branch name
|
|
||||||
id: branch_name
|
id: branch_name
|
||||||
uses: ./.gitea/actions/getTagSafeRef
|
uses: ./.github/actions/getTagSafeRef
|
||||||
|
|
||||||
|
- name: Print branch_name
|
||||||
|
run: ${{ steps.branch_name.outputs.branch_name }}
|
||||||
|
|
||||||
# - name: Build and push image
|
# - name: Build and push image
|
||||||
# id: docker_build
|
# id: docker_build
|
||||||
# uses: ./.gitea/actions/build
|
# uses: ./.github/actions/buildDockerImage
|
||||||
# with:
|
# with:
|
||||||
# tag: ${{ steps.branch_name.outputs.branch_name }}
|
# tag: ${{ steps.branch_name.outputs.branch_name }}
|
||||||
# REGISTRY_ACCESS_TOKEN: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
|
||||||
# REGISTRY_USER: ${{ gitea.actor }}
|
|
||||||
|
|
||||||
- name: Create environment file
|
# - name: Deploy application
|
||||||
run: |
|
# uses: ./.github/actions/deploy
|
||||||
cat > .env << EOF
|
# with:
|
||||||
TOLGEE_API_URL=${{ vars.TOLGEE_API_URL }}
|
# project_name: ${{ steps.branch_name.outputs.branch_name }}
|
||||||
TOLGEE_API_KEY=${{ secrets.TOLGEE_API_KEY }}
|
# url: '${{ steps.branch_name.outputs.branch_name }}.phoenix.klemp.local'
|
||||||
TRANSLATION_CACHE_TTL=${{ vars.TRANSLATION_CACHE_TTL }}
|
# image_url: ${{ steps.docker_build.outputs.image_url }}
|
||||||
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 "========================="
|
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
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 "========================="
|
|
||||||
@@ -1,27 +1,20 @@
|
|||||||
|
version: '3.8'
|
||||||
networks:
|
networks:
|
||||||
tolgee:
|
|
||||||
name: tolgee
|
|
||||||
external: true
|
|
||||||
default:
|
default:
|
||||||
name: traefik-proxy
|
external:
|
||||||
external: true
|
name: traefik-proxy
|
||||||
|
|
||||||
services:
|
services:
|
||||||
app:
|
app:
|
||||||
image: ${IMAGE_URL}
|
image: ${IMAGE_URL}
|
||||||
container_name: ${PROJECT_NAME}-app
|
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
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
- internal
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.docker.network=traefik-proxy
|
- 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.routers.${PROJECT_NAME}.rule=Host(`${URL}`)
|
||||||
|
- traefik.http.routers.${PROJECT_NAME}.tls.certresolver=letsencrypt
|
||||||
- traefik.http.services.${PROJECT_NAME}.loadbalancer.server.port=3000
|
- traefik.http.services.${PROJECT_NAME}.loadbalancer.server.port=3000
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class LanguageService {
|
|||||||
|
|
||||||
protected async fetchTranslations(languageCodes: string | string[]) {
|
protected async fetchTranslations(languageCodes: string | string[]) {
|
||||||
const url = new URL(`${env.TOLGEE_API_URL}/v2/projects/2/export`)
|
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('format', 'JSON')
|
||||||
url.searchParams.append('zip', 'true')
|
url.searchParams.append('zip', 'true')
|
||||||
@@ -77,6 +76,7 @@ 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')
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user