frappe_docker/.github/workflows/build_system_image.yml
2023-12-09 16:49:07 +03:00

86 lines
4.1 KiB
YAML

name: build system Image base on json config provided
# run-name: ${{ github.actor }} update 🚀
on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
branches: [main]
workflow_call:
# on:
# workflow_run:
# workflows: ["Master Workflow"]
# types:
# - completed
jobs:
job-image-build:
runs-on:
- self-hosted
# - ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
# with:
# repository: malnozili/remittance_image_builder
# token: ${{ secrets.GITHUB_TOKEN }}
- name: login to harb
uses: docker/login-action@v1
with:
registry: harbor.fintechsys.net
username: ${{ secrets.PHEE_HARBOR_USERNAME }}
password: ${{ secrets.PHEE_HARBOR_PASSWORD }}
- name: Execute custom commands
run: |
git clone https://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@github.com/malnozili/remittance_image_builder.git
cd remittance_image_builder
../build_network_company_image.sh --tag="remittance_network_agent/${{ github.event.pull_request.head.ref }}:latest" --token="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" --frappe-path="https://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@github.com/fintechsys/frappe.git" --frappe-branch=${{ github.event.pull_request.head.ref }}
# docker image ls
# docker tag remittance_network_agent/${{ vars.BRANCH_NAME }}:latest harbor.fintechsys.net/frappe-systems/${{ vars.BRANCH_NAME }}:latest
# docker push harbor.fintechsys.net/frappe-systems/remittance_network_agent/${{ vars.BRANCH_NAME }}:latest
#Creat Bench and sites
- name: Create first bench
run: |
cp example.env ~/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=`erp.fintechsys.net`/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/erpnext-one.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 ${{ vars.BRANCH_NAME }} \
--env-file ~/gitops/${{ github.event.pull_request.head.ref }}.env \
-f compose.yaml \
-f overrides/compose.redis.yaml \
-f overrides/compose.multi-bench.yaml \
-f overrides/compose.multi-bench-ssl.yaml config > ~/gitops/${{ github.event.pull_request.head.ref }}.yaml
- name: Deploy the container
run: |
docker-compose --project-name ${{ vars.BRANCH_NAME }} -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 -T backend \
bench new-site --no-mariadb-socket --mariadb-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 }} ${{ github.event.pull_request.head.ref }}