diff --git a/.github/workflows/deploy-to-beta.yml b/.github/workflows/deploy-to-beta.yml index 0c0fcabb..1cacb18c 100644 --- a/.github/workflows/deploy-to-beta.yml +++ b/.github/workflows/deploy-to-beta.yml @@ -84,7 +84,9 @@ jobs: username: ${{ secrets.TOBY_VPS_USERNAME }} password: ${{ secrets.TOBY_VPS_PASSWORD }} script_stop: true - script: BRANCH_NAME=${{ env.BRANCH_NAME }} make --makefile=/blumilk/beta/projects/toby/Makefile beta-deploy + script: | + cd /blumilk/beta/projects/toby + BRANCH_NAME=${{ env.BRANCH_NAME }} make beta-deploy - name: comment PR that changes has been deployed to beta if: github.event_name != 'workflow_dispatch' diff --git a/.github/workflows/deploy-to-prod.yml b/.github/workflows/deploy-to-prod.yml index 0c0d4073..0df060ff 100644 --- a/.github/workflows/deploy-to-prod.yml +++ b/.github/workflows/deploy-to-prod.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: appleboy/ssh-action@v0.1.5 env: - BRANCH_NAME: $GITHUB_REF_NAME + BRANCH_NAME: "main" with: timeout: 10s command_timeout: 10m @@ -26,5 +26,6 @@ jobs: username: ${{ secrets.TOBY_VPS_USERNAME }} password: ${{ secrets.TOBY_VPS_PASSWORD }} script_stop: true - script: BRANCH_NAME=${{ env.BRANCH_NAME }} make --makefile=/blumilk/production/toby/Makefile prod-deploy - + script: | + cd /blumilk/production/toby + BRANCH_NAME=${{ env.BRANCH_NAME }} make prod-deploy diff --git a/Makefile b/Makefile index 9a6f1221..03c55840 100644 --- a/Makefile +++ b/Makefile @@ -6,18 +6,34 @@ PROD_DOCKER_EXEC=docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} exec --wo .PHONY: beta-deploy beta-deploy: - echo "${BRANCH_NAME}" && \ git fetch && \ git checkout --force "${BRANCH_NAME}" && \ git pull && \ - COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose -f ${DOCKER_COMPOSE_BETA_FILENAME} build --pull && \ + COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --file ${DOCKER_COMPOSE_BETA_FILENAME} build --pull && \ docker compose --file ${DOCKER_COMPOSE_BETA_FILENAME} up --detach && \ - ${BETA_DOCKER_EXEC} toby-beta-php post-deploy-actions && \ - ${BETA_DOCKER_EXEC} toby-beta-worker post-deploy-actions && \ - ${BETA_DOCKER_EXEC} toby-beta-scheduler post-deploy-actions + ${BETA_DOCKER_EXEC} toby-beta-php bash post-deploy-actions.sh && \ + ${BETA_DOCKER_EXEC} toby-beta-worker bash post-deploy-actions.sh && \ + ${BETA_DOCKER_EXEC} toby-beta-scheduler bash post-deploy-actions.sh .PHONY: beta-reload-config beta-reload-config: ${BETA_DOCKER_EXEC} toby-beta-php bash reload-config.sh && \ ${BETA_DOCKER_EXEC} toby-beta-worker bash reload-config.sh && \ ${BETA_DOCKER_EXEC} toby-beta-scheduler bash reload-config.sh + +.PHONY: prod-deploy +prod-deploy: + git fetch && \ + git checkout --force "${BRANCH_NAME}" && \ + git pull && \ + COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} build --pull && \ + docker compose --file ${DOCKER_COMPOSE_PROD_FILENAME} up --detach && \ + ${PROD_DOCKER_EXEC} toby-prod-php bash post-deploy-actions.sh && \ + ${PROD_DOCKER_EXEC} toby-prod-worker bash post-deploy-actions.sh && \ + ${PROD_DOCKER_EXEC} toby-prod-scheduler bash post-deploy-actions.sh + +.PHONY: prod-reload-config +prod-reload-config: + ${PROD_DOCKER_EXEC} toby-prod-php bash reload-config.sh && \ + ${PROD_DOCKER_EXEC} toby-prod-worker bash reload-config.sh && \ + ${PROD_DOCKER_EXEC} toby-prod-scheduler bash reload-config.sh diff --git a/environment/scripts/post-deploy-actions.sh b/environment/scripts/post-deploy-actions.sh index f4033375..b6f41109 100644 --- a/environment/scripts/post-deploy-actions.sh +++ b/environment/scripts/post-deploy-actions.sh @@ -3,6 +3,6 @@ # -e is for "automatic error detection", tell shell to abort any time an error occurred set -e -php artisan migrate --force && \ - php artisan route:cache && \ +php /application/artisan migrate --force && \ + php /application/artisan route:cache && \ bash reload-config.sh diff --git a/environment/scripts/reload-config.sh b/environment/scripts/reload-config.sh index bb4c59cf..c3e57e98 100644 --- a/environment/scripts/reload-config.sh +++ b/environment/scripts/reload-config.sh @@ -3,4 +3,4 @@ # -e is for "automatic error detection", tell shell to abort any time an error occurred set -e -php artisan config:clear && php artisan config:cache +php /application/artisan config:clear && php /application/artisan config:cache diff --git a/readme.md b/readme.md index 22bd1cc4..897ab274 100644 --- a/readme.md +++ b/readme.md @@ -108,3 +108,5 @@ Docker container: ``` docker-compose run --rm -e XDEBUG_MODE=off php php artisan test ``` + +new content for ci cd test.