Use Gitea actions instead of woodpecker
This commit is contained in:
parent
c2cc959309
commit
07b9ebb487
104
.gitea/workflows/build.yaml
Normal file
104
.gitea/workflows/build.yaml
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
name: Build & Publish Backend
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "api/**"
|
||||||
|
- "frontend/**"
|
||||||
|
- "telegram_bot/**"
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Check changed directories
|
||||||
|
uses: https://github.com/dorny/paths-filter@v2
|
||||||
|
id: changes
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
api:
|
||||||
|
- 'api/**'
|
||||||
|
frontend:
|
||||||
|
- 'frontend/**'
|
||||||
|
telegram_bot:
|
||||||
|
- 'telegram_bot/**'
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
- name: "[Frontend] Docker meta"
|
||||||
|
if: steps.changes.outputs.frontend == 'true'
|
||||||
|
id: frontend-meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: git.flokaiser.com/dhbw/aktienbot-frontend
|
||||||
|
tags: |
|
||||||
|
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
# API
|
||||||
|
- name: "[API] Docker meta"
|
||||||
|
if: steps.changes.outputs.api == 'true'
|
||||||
|
id: api-meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: git.flokaiser.com/dhbw/aktienbot-api
|
||||||
|
tags: |
|
||||||
|
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
# Bot
|
||||||
|
- name: "[Bot] Docker meta"
|
||||||
|
if: steps.changes.outputs.telegram_bot == 'true'
|
||||||
|
id: bot-meta
|
||||||
|
uses: https://github.com/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: git.flokaiser.com/dhbw/aktienbot-bot
|
||||||
|
tags: |
|
||||||
|
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
|
||||||
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
|
- name: Get get-docker.sh
|
||||||
|
run: curl -fsSL https://get.docker.com -o get-docker.sh
|
||||||
|
|
||||||
|
- name: Install docker
|
||||||
|
run: sh get-docker.sh
|
||||||
|
|
||||||
|
- name: Login to Registry
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.flokaiser.com
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
# Frontend
|
||||||
|
- name: "[Frontend] Build and push"
|
||||||
|
if: steps.changes.outputs.frontend == 'true'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: frontend/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.frontend-meta.outputs.tags }}
|
||||||
|
|
||||||
|
# API
|
||||||
|
- name: "[Frontend] Build and push"
|
||||||
|
if: steps.changes.outputs.api == 'true'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: api/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.api-meta.outputs.tags }}
|
||||||
|
|
||||||
|
# Bot
|
||||||
|
- name: "[Bot] Build and push"
|
||||||
|
if: steps.changes.outputs.bot == 'true'
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
file: telegram_bot/Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.bot-meta.outputs.tags }}
|
@ -1,87 +0,0 @@
|
|||||||
pipeline:
|
|
||||||
generate_docker_tag:
|
|
||||||
image: golang
|
|
||||||
commands:
|
|
||||||
- echo -n "${CI_COMMIT_BRANCH//\//-}-${CI_COMMIT_SHA:0:8}, latest" > .tags
|
|
||||||
when:
|
|
||||||
path: [ "frontend/**", "telegram_bot/**", "api/**" ]
|
|
||||||
event: push
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------- API --------------------------------------
|
|
||||||
build_api:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo:
|
|
||||||
from_secret: repo_api
|
|
||||||
username:
|
|
||||||
from_secret: username
|
|
||||||
password:
|
|
||||||
from_secret: password
|
|
||||||
registry:
|
|
||||||
from_secret: registry
|
|
||||||
dockerfile: api/Dockerfile
|
|
||||||
platforms: linux/amd64
|
|
||||||
when:
|
|
||||||
path: "api/**"
|
|
||||||
event: push
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------- Bot --------------------------------------
|
|
||||||
build_bot:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo:
|
|
||||||
from_secret: repo_bot
|
|
||||||
username:
|
|
||||||
from_secret: username
|
|
||||||
password:
|
|
||||||
from_secret: password
|
|
||||||
registry:
|
|
||||||
from_secret: registry
|
|
||||||
dockerfile: telegram_bot/Dockerfile
|
|
||||||
platforms: linux/amd64
|
|
||||||
when:
|
|
||||||
path: "telegram_bot/**"
|
|
||||||
event: push
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------- Frontend --------------------------------------
|
|
||||||
build_frontend:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
|
||||||
settings:
|
|
||||||
repo:
|
|
||||||
from_secret: repo_frontend
|
|
||||||
username:
|
|
||||||
from_secret: username
|
|
||||||
password:
|
|
||||||
from_secret: password
|
|
||||||
registry:
|
|
||||||
from_secret: registry
|
|
||||||
dockerfile: frontend/Dockerfile
|
|
||||||
platforms: linux/amd64
|
|
||||||
when:
|
|
||||||
path: "frontend/**"
|
|
||||||
event: push
|
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------------- Deploy --------------------------------------
|
|
||||||
deploy:
|
|
||||||
image: appleboy/drone-ssh
|
|
||||||
network_mode: host
|
|
||||||
settings:
|
|
||||||
host:
|
|
||||||
from_secret: ssh_host
|
|
||||||
username:
|
|
||||||
from_secret: ssh_user
|
|
||||||
password:
|
|
||||||
from_secret: ssh_password
|
|
||||||
script:
|
|
||||||
- cd ~/docker-compose-files/telegram_aktien_bot
|
|
||||||
- docker-compose pull
|
|
||||||
- docker-compose --env-file ~/docker-compose-env/telegram_aktien_bot.env up -d
|
|
||||||
when:
|
|
||||||
path: [ "frontend/**", "telegram_bot/**", "api/**" ]
|
|
||||||
event: push
|
|
||||||
|
|
||||||
branches: main
|
|
@ -1,14 +1,18 @@
|
|||||||
FROM python:3.11-slim
|
FROM python:3.10-slim
|
||||||
|
|
||||||
# Change the working directory to the root of the project
|
# Change the working directory to the root of the project
|
||||||
WORKDIR /srv/flask_app
|
WORKDIR /srv/flask_app
|
||||||
|
|
||||||
|
# Create venv
|
||||||
|
RUN python -m venv myvenv
|
||||||
|
ENV PATH="myvenv/bin:$PATH"
|
||||||
|
|
||||||
# Install the dependencies
|
# Install the dependencies
|
||||||
COPY telegram_bot/requirements.txt /srv/flask_app/
|
COPY requirements.txt /srv/flask_app/
|
||||||
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
|
RUN pip install -r requirements.txt --src /usr/local/src --no-warn-script-location
|
||||||
|
|
||||||
# Copy the source code to the working directory
|
# Copy the source code to the working directory
|
||||||
COPY telegram_bot /srv/flask_app
|
COPY . /srv/flask_app
|
||||||
|
|
||||||
# Change file permissions
|
# Change file permissions
|
||||||
RUN chmod +x ./deploy/start.sh
|
RUN chmod +x ./deploy/start.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user