Skip to content

Commit 4313248

Browse files
committed
🔨 Add pre/post deployment scripts and update Dependabot configuration
1 parent 65a0661 commit 4313248

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ version: 2
22
updates:
33
- package-ecosystem: "docker-compose"
44
directory: "/"
5-
assignees:
6-
- "dependabot"
75
labels:
86
- "dependency"
97
- "docker"

.github/workflows/deploy-production.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ jobs:
4747
let count=count-1
4848
done
4949
echo "OK: Connection established!"
50-
- name: Stop services
51-
run: sleep 3 && ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && docker compose down --remove-orphans'
50+
- name: Run pre-deployment script
51+
run: sleep 3 && ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && ./scripts/pre-deploy.sh'
5252
- name: Backup
5353
run: ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && ./scripts/backup.sh'
54+
- name: Stop services
55+
run: ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && docker compose down --remove-orphans'
5456
- name: Update to latest version
5557
run: ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && git checkout prod && git fetch origin prod && git reset --hard origin/prod && docker compose pull'
5658
- name: Start services
@@ -66,3 +68,5 @@ jobs:
6668
let count=count-1
6769
done
6870
echo "OK: Deployment successful!"
71+
- name: Run post-deployment script
72+
run: ssh SERVER 'cd ${{ secrets.DEPLOY_PROJECT_DIR }} && ./scripts/post-deploy.sh'

scripts/post-deploy.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
5+
## --- Base --- ##
6+
# Getting path of this script file:
7+
_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8+
_PROJECT_DIR="$(cd "${_SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd)"
9+
cd "${_PROJECT_DIR}" || exit 2
10+
11+
# Loading .env file (if exists):
12+
if [ -f ".env" ]; then
13+
# shellcheck disable=SC1091
14+
source .env
15+
fi
16+
## --- Base --- ##
17+
18+
19+
echo "[INFO]: Running post-deploy script..."
20+
21+
echo "[OK]: Done."

scripts/pre-deploy.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
5+
## --- Base --- ##
6+
# Getting path of this script file:
7+
_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8+
_PROJECT_DIR="$(cd "${_SCRIPT_DIR}/.." >/dev/null 2>&1 && pwd)"
9+
cd "${_PROJECT_DIR}" || exit 2
10+
11+
# Loading .env file (if exists):
12+
if [ -f ".env" ]; then
13+
# shellcheck disable=SC1091
14+
source .env
15+
fi
16+
## --- Base --- ##
17+
18+
19+
echo "[INFO]: Running pre-deploy script..."
20+
21+
echo "[OK]: Done."

0 commit comments

Comments
 (0)