Compare commits
9 Commits
fab34ee325
...
feature/br
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bf4036603 | ||
|
|
a0b9e5b692 | ||
|
|
0938ce1270 | ||
|
|
2c78aeeddd | ||
|
|
c56f1f701f | ||
|
|
0b523e75fd | ||
|
|
14170e3261 | ||
|
|
32b391d15d | ||
| 74b6092838 |
36
.gitea/actions/build/action.yml
Normal file
36
.gitea/actions/build/action.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: Build docker image
|
||||||
|
description: 'builds 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 }}
|
||||||
|
|
||||||
|
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: ${{ 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/action.yml
Normal file
93
.gitea/actions/deploy/action.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 "========================="
|
||||||
23
.gitea/actions/getTagSafeRef/action.yml
Normal file
23
.gitea/actions/getTagSafeRef/action.yml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
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: Create tag safe branch name
|
||||||
|
id: get-branch
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
BRANCH_NAME="${{ github.ref }}"
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -38,27 +38,24 @@ jobs:
|
|||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: bun --bun run format:check
|
run: bun --bun run format:check
|
||||||
|
|
||||||
build-docker-image:
|
# build-docker-image:
|
||||||
runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
steps:
|
# steps:
|
||||||
- name: Checkout code
|
# - name: Set up Docker Build
|
||||||
uses: actions/checkout@v4
|
# uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
# - name: Log in to registry
|
||||||
uses: docker/setup-buildx-action@v3
|
# uses: docker/login-action@v3
|
||||||
|
# with:
|
||||||
- name: Log in to registry
|
# registry: ${{ vars.INSTANCE_URL }}
|
||||||
uses: docker/login-action@v3
|
# username: ${{ github.actor }}
|
||||||
with:
|
# password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
||||||
registry: git.klemp.dev
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
|
|
||||||
|
|
||||||
# - name: Build and push image
|
# - name: Build and push image
|
||||||
# uses: docker/build-push-action@v6
|
# uses: docker/build-push-action@v6
|
||||||
# with:
|
# with:
|
||||||
# push: true
|
# push: true
|
||||||
# tags: ${{ GITEA_DOMAIN }}/${{ env.RESULT_IMAGE_NAME }}:${{ gitea.ref }}
|
# tags: ${{ vars.INSTANCE_URL }}/tech-reborn/phoenix:${{ github.sha }}
|
||||||
|
|
||||||
# type-check:
|
# type-check:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
|
|||||||
29
.gitea/workflows/commentDeploy.yml
Normal file
29
.gitea/workflows/commentDeploy.yml
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: ChatOps Deploy
|
||||||
|
on: issue_comment
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testing:
|
||||||
|
if: |
|
||||||
|
gitea.event.issue.pull_request &&
|
||||||
|
startsWith(gitea.event.comment.body, '/deploy')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Get tag safe branch name
|
||||||
|
id: branch_name
|
||||||
|
uses: ./.gitea/actions/getTagSafeRef
|
||||||
|
|
||||||
|
- name: Print branch_name
|
||||||
|
run: echo "${{ steps.branch_name.outputs.branch_name }}"
|
||||||
|
|
||||||
|
# - name: Build and push image
|
||||||
|
# id: docker_build
|
||||||
|
# uses: ./.github/actions/buildDockerImage
|
||||||
|
# with:
|
||||||
|
# tag: ${{ steps.branch_name.outputs.branch_name }}
|
||||||
|
|
||||||
|
# - name: Deploy application
|
||||||
|
# uses: ./.github/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 }}
|
||||||
20
docker-compose.yml
Normal file
20
docker-compose.yml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
version: '3.8'
|
||||||
|
networks:
|
||||||
|
default:
|
||||||
|
external:
|
||||||
|
name: traefik-proxy
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: ${IMAGE_URL}
|
||||||
|
container_name: ${PROJECT_NAME}-app
|
||||||
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- traefik
|
||||||
|
- internal
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.docker.network=traefik-proxy
|
||||||
|
- 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
|
||||||
Reference in New Issue
Block a user