Skip to content

Commit

Permalink
#115 - Adjust deployment (#272)
Browse files Browse the repository at this point in the history
* readme changes for beta deploy workflow

* debug BRANCH_NAME in Makefile

* fix Makefile scripts

* fix path to artisan in environment scripts

* improve deploy workflows and Makefile

* typo
  • Loading branch information
mtracz authored Dec 7, 2022
1 parent 766e006 commit 8542323
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/deploy-to-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/deploy-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: appleboy/[email protected]
env:
BRANCH_NAME: $GITHUB_REF_NAME
BRANCH_NAME: "main"
with:
timeout: 10s
command_timeout: 10m
Expand All @@ -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
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions environment/scripts/post-deploy-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion environment/scripts/reload-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ Docker container:
```
docker-compose run --rm -e XDEBUG_MODE=off php php artisan test
```

new content for ci cd test.

0 comments on commit 8542323

Please sign in to comment.