frappe_docker/.github/workflows/build_system_image.yml
2023-12-17 12:15:04 +03:00

67 lines
4 KiB
YAML

name: build system Image base on json config provided
on:
# workflow_dispatch:
pull_request:
types: [opened, reopened]
branches: [main]
jobs:
job-image-build:
runs-on:
- self-hosted
# - ubuntu-latest
steps:
- name: checkout Script content
uses: actions/checkout@v2
# - name: Create directory
# run: |
# mkdir ~/gitops
- name: Create first bench
run: |
cp example.env ~/gitops/${{ github.event.pull_request.head.ref }}.env
sed -i 's/FRAPPE_SITE_NAME_HEADER=/FRAPPE_SITE_NAME_HEADER=${{ github.event.pull_request.head.ref }}/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
sed -i 's/DB_PASSWORD=123/DB_PASSWORD==${{ vars.MARIADB_PASSWORD }}/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
echo "PORTS= $((8081 + RANDOM % 919))" >> ~/gitops/${{ github.event.pull_request.head.ref }}.env
echo PORTS= $((8081 + RANDOM % 919))
# sed -i 's/DBPASSWORD=/DP=DBPASSWORD=${{ vars.MARIADB_PASSWORD }}/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# sed -i 's/PORTS=/PORTS= $port1 /g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# sed -i 's/DB_PASSWORD=123/DB_PASSWORD=${{ vars.MARIADB_PASSWORD }}/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# sed -i 's/DB_HOST=/DB_HOST=mariadb-database/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# sed -i 's/DB_PORT=/DB_PORT=3306/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# sed -i 's/SITES=`${{ github.event.pull_request.head.ref }}`/SITES=\`${{ github.event.pull_request.head.ref }}\`/g' ~/gitops/${{ github.event.pull_request.head.ref }}.env
# echo 'ROUTER=${{ github.event.pull_request.head.ref }}' >> ~/gitops/${{ github.event.pull_request.head.ref }}.env
# echo "BENCH_NETWORK=${{ github.event.pull_request.head.ref }}" >> ~/gitops/${{ github.event.pull_request.head.ref }}.env
- name: Create a yaml file to deploy container
run: |
docker-compose --project-name ${{ github.event.pull_request.head.ref }} \
--env-file ~/gitops/${{ github.event.pull_request.head.ref }}.env \
-f pwd.yml config > ~/gitops/${{ github.event.pull_request.head.ref }}.yaml
- name: Deploy the container
run: |
docker-compose --project-name ${{ github.event.pull_request.head.ref }} -f ~/gitops/${{ github.event.pull_request.head.ref }}.yaml up -d
- name: Create the site
run: |
docker-compose --project-name ${{ github.event.pull_request.head.ref }} exec backend \
bench new-site --no-mariadb-socket --admin-password=${{ vars.MARIADB_PASSWORD }} --db-root-password=${{ vars.MARIADB_PASSWORD }} --install-app erpnext --set-default ${{ github.event.pull_request.head.ref }}
# - name: Create the site
# run: |
# docker-compose --project-name ${{ github.event.pull_request.head.ref }} exec -T backend \
# bench new-site --no-mariadb-socket --db-root-password=${{ vars.MARIADB_PASSWORD }} --db-root-password=${{ vars.MARIADB_PASSWORD }} --install-app erpnext --set-default ${{ github.event.pull_request.head.ref }}
# bench new-site --no-mariadb-socket --db-root-password ${{ vars.MARIADB_PASSWORD }} --install-app hrms --set-default \
# --install-app rule_management --install-app remittance_base --install-app remittance --install-app bulk_remittance --install-app remittance_stellar_integration \
# --install-app client_account_management --install-app teller_for_erpnext --install-app teller_for_agent \
# --install-app remittance_agent_service --install-app payment_management --install-app bank_services --install-app remittance_customize \
# --install-app remittance_network_manager --install-app erpnext_theme --install-app remittance_website --admin-password ${{ vars.MARIADB_PASSWORD }} --set-default ${{ github.event.pull_request.head.ref }}