Odoo18-Base/.gitea/workflows/init_setup_environment.yml

117 lines
3.3 KiB
YAML
Raw Permalink Normal View History

name: Setup Native Action
on:
push:
2025-01-16 10:15:06 +07:00
branches: [main,dev]
2025-01-15 14:47:49 +07:00
pull_request:
2025-01-16 10:15:06 +07:00
branches: [main,dev]
2025-01-15 15:27:29 +07:00
# options in commit : @native @docker @push_image @run_test @no_cleanup @restore_db
jobs:
2025-01-15 12:17:17 +07:00
native:
if: contains(github.event.head_commit.message, '@native')
2025-01-15 14:32:21 +07:00
runs-on: ubuntu-latest
env:
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_SERVER: ${{ vars.DB_SERVER }}
DB_PORT: ${{ vars.DB_PORT }}
strategy:
matrix:
python-version: [3.12.7]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Create Python virtual environment
run: python -m venv venv
- name: Activate virtual environment and install dependencies
run: make install
- name: Generate Config
run: make gen_config
- name: Run Tests
run: make run_test
2025-01-15 14:32:21 +07:00
docker:
if: contains(github.event.head_commit.message, '@docker')
2025-01-15 18:35:27 +07:00
runs-on: host
2025-01-15 12:30:29 +07:00
env:
DB_USER: ${{ secrets.DB_USER }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_SERVER: ${{ vars.DB_SERVER }}
DB_PORT: ${{ vars.DB_PORT }}
strategy:
matrix:
python-version: [3.12.7]
steps:
2025-01-15 12:17:17 +07:00
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
2025-01-15 18:35:27 +07:00
# - name: Set up Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
2025-01-15 12:20:50 +07:00
2025-01-15 12:17:17 +07:00
- name: Create Python virtual environment
run: python -m venv venv
- name: Activate virtual environment and install dependencies
2025-01-15 16:18:06 +07:00
run: ./venv/bin/pip install python-dotenv
2025-01-15 12:17:17 +07:00
- name: Update Tag
run: make update_tag CURR_BRANCH=${{ github.ref_name }}
2025-01-15 12:20:50 +07:00
- name: Install Docker compose
uses: KengoTODA/actions-setup-docker-compose@v1
with:
version: '2.14.2'
- name: Stop Server Docker
run: make stop_server_docker
- name: Generate Config
run: make gen_config_docker
- name: Build Image
run: make build_image
- name: Start Server
run: make run_server_docker
- name: Sleep for 10 seconds
2025-01-15 18:35:27 +07:00
run: sleep 10
- name: Restore Database
2025-01-15 15:27:29 +07:00
if: contains(github.event.head_commit.message, '@restore_db')
run: make restore_database_docker
- name: Run Tests
if: contains(github.event.head_commit.message, '@run_test')
run: make run_test_docker
- name: Login Docker hub
2025-01-15 12:01:11 +07:00
if: contains(github.event.head_commit.message, '@push_image')
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin ${{ secrets.DOCKER_HUB }}
2025-01-15 15:30:29 +07:00
- name: Push Image
if: contains(github.event.head_commit.message, '@push_image')
run: make push_image
- name: Logout Docker hub
2025-01-15 12:01:11 +07:00
if: contains(github.event.head_commit.message, '@push_image')
run: docker logout ${{ secrets.DOCKER_HUB }}
- name: Clean Up
if: "!contains(github.event.head_commit.message, '@no_cleanup')"
run: make clean_up