Skip to content

Commit a9fce45

Browse files
authored
Merge pull request #28 from PeterVinter/develop
feat: implement develop/main branch structure
2 parents 80cf57d + b641994 commit a9fce45

File tree

4 files changed

+91
-44
lines changed

4 files changed

+91
-44
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, develop ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ main, develop ]
88

99
jobs:
1010
shellcheck:

.github/workflows/update-changelog.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
types: [closed]
66
branches:
77
- main
8+
- develop
89

910
jobs:
1011
update-changelog:
@@ -20,7 +21,7 @@ jobs:
2021
- uses: actions/checkout@v4
2122
with:
2223
fetch-depth: 0
23-
ref: main
24+
ref: ${{ github.base_ref }}
2425
token: ${{ secrets.PAT_TOKEN }}
2526

2627
- name: Get PR title and body
@@ -156,7 +157,8 @@ jobs:
156157
git config --global user.name "github-actions[bot]"
157158
158159
# Create branch and commit changes with error handling
159-
BRANCH_NAME="bot/update-changelog-v${NEW_VERSION}"
160+
TARGET_BRANCH="${{ github.base_ref }}"
161+
BRANCH_NAME="bot/update-changelog-v${NEW_VERSION}-${TARGET_BRANCH}"
160162
if ! git checkout -b "$BRANCH_NAME"; then
161163
echo "Error: Failed to create new branch"
162164
exit 1
@@ -185,13 +187,14 @@ jobs:
185187
### Changes
186188
- Type: ${CHANGE_TYPE}
187189
- Original PR Title: ${PR_TITLE}
190+
- Target Branch: ${TARGET_BRANCH}
188191
189192
This is an automated update by the changelog workflow."
190193
191194
if ! gh pr create \
192195
--title "docs: update changelog for v${NEW_VERSION}" \
193196
--body "$PR_BODY" \
194-
--base main \
197+
--base "$TARGET_BRANCH" \
195198
--head "$BRANCH_NAME"; then
196199
echo "Warning: Failed to create PR, but changes were pushed to branch"
197200
fi

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,45 @@ Logs are stored in:
8383

8484
## Development
8585

86+
### Branch Structure
87+
88+
This repository follows a simplified GitFlow workflow with two main branches:
89+
90+
- `main`: The stable branch containing production-ready code
91+
- All releases are tagged from this branch
92+
- Protected branch requiring PR reviews
93+
- Must pass all CI checks before merging
94+
95+
- `develop`: The development branch where features are integrated
96+
- All feature branches merge here first
97+
- Contains latest development changes
98+
- Must pass CI checks before merging
99+
100+
#### Working with Branches
101+
102+
1. Feature Development
103+
```bash
104+
git checkout develop
105+
git checkout -b feature/your-feature
106+
# Make your changes
107+
git push origin feature/your-feature
108+
# Create PR to develop
109+
```
110+
111+
2. Bug Fixes
112+
```bash
113+
git checkout develop
114+
git checkout -b fix/bug-description
115+
# Fix the bug
116+
git push origin fix/bug-description
117+
# Create PR to develop
118+
```
119+
120+
3. Release Process
121+
- Features are merged into `develop`
122+
- When ready for release, `develop` is merged into `main`
123+
- Release tags are created from `main`
124+
86125
### Project Management
87126

88127
This project uses GitHub's project management features to track issues, pull requests, and milestones. We follow a structured workflow:

startup_docker_container.sh

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ SHUTDOWN_LIST="shutdowned.txt"
66

77
log_message() {
88
local message="$1"
9+
local level="${2:-INFO}" # Default level is INFO
910
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
10-
echo "[$timestamp] $message" | tee -a "$LOG_FILE"
11+
echo "[$timestamp] [$level] $message" | tee -a "$LOG_FILE"
1112
}
1213

1314
# Function to check container status
@@ -25,6 +26,19 @@ check_container() {
2526
fi
2627
}
2728

29+
# Function to get container details
30+
get_container_details() {
31+
local name=$1
32+
local details=$(docker inspect "$name" 2>/dev/null)
33+
if [ $? -eq 0 ]; then
34+
local ip=$(echo "$details" | grep -m 1 '"IPAddress":' | cut -d '"' -f 4)
35+
local created=$(echo "$details" | grep -m 1 '"Created":' | cut -d '"' -f 4)
36+
echo "IP: $ip, Created: $created"
37+
else
38+
echo "No details available"
39+
fi
40+
}
41+
2842
# Function to reverse file content (compatible with both macOS and Linux)
2943
reverse_file() {
3044
if command -v tac >/dev/null 2>&1; then
@@ -36,66 +50,57 @@ reverse_file() {
3650

3751
# Check if shutdown list exists
3852
if [ ! -f "$SHUTDOWN_LIST" ]; then
39-
log_message "No shutdown list found at $SHUTDOWN_LIST. Nothing to start."
53+
log_message "No shutdown list found at $SHUTDOWN_LIST. Nothing to start." "WARNING"
4054
exit 1
4155
fi
4256

43-
log_message "Starting Docker containers from shutdown list..."
57+
log_message "Starting Docker containers from shutdown list..." "INFO"
4458

4559
# Read the shutdown list in reverse order (to respect dependencies)
4660
while IFS='|' read -r name image cmd ports networks; do
47-
log_message "Processing container: $name"
61+
log_message "Processing container: $name" "INFO"
4862

4963
# Check container status
5064
container_status=$(check_container "$name")
5165

52-
case $container_status in
66+
case "$container_status" in
5367
"running")
54-
log_message "Container $name is already running, skipping..."
55-
continue
68+
log_message "Container $name is already running" "INFO"
69+
details=$(get_container_details "$name")
70+
log_message "Container details - $details" "INFO"
5671
;;
5772
"stopped")
58-
log_message "Container $name exists but is stopped, starting it..."
73+
log_message "Starting stopped container: $name" "INFO"
5974
if docker start "$name"; then
60-
log_message "Successfully started existing container: $name"
75+
details=$(get_container_details "$name")
76+
log_message "Successfully started container $name" "SUCCESS"
77+
log_message "Container details - $details" "INFO"
6178
else
62-
log_message "Failed to start existing container: $name"
79+
log_message "Failed to start container $name" "ERROR"
6380
fi
64-
continue
6581
;;
6682
"none")
67-
# Process port mappings
68-
port_args=""
69-
if [ ! -z "$ports" ]; then
70-
# Convert semicolon-separated port mappings into multiple -p arguments
71-
for port_mapping in ${ports//;/ }; do
72-
if [ ! -z "$port_mapping" ]; then
73-
port_args="$port_args -p $port_mapping"
74-
fi
75-
done
76-
fi
77-
78-
# Process network
79-
network_arg=""
80-
if [ ! -z "$networks" ]; then
81-
# Get first network (before semicolon)
82-
network=$(echo "$networks" | cut -d';' -f1)
83-
if [ ! -z "$network" ]; then
84-
network_arg="--network $network"
85-
fi
86-
fi
87-
83+
log_message "Creating new container: $name" "INFO"
8884
# Create and start the container
89-
docker_cmd="docker run -d --name ${name} ${port_args} ${network_arg} ${image} ${cmd}"
90-
log_message "Creating new container: $docker_cmd"
91-
92-
if eval "$docker_cmd"; then
93-
log_message "Successfully created and started container: $name"
85+
if [ -z "$networks" ]; then
86+
if docker run -d --name "$name" $ports "$image" $cmd; then
87+
details=$(get_container_details "$name")
88+
log_message "Successfully created and started container $name" "SUCCESS"
89+
log_message "Container details - $details" "INFO"
90+
else
91+
log_message "Failed to create container $name" "ERROR"
92+
fi
9493
else
95-
log_message "Failed to create and start container: $name"
94+
if docker run -d --name "$name" $ports --network "$networks" "$image" $cmd; then
95+
details=$(get_container_details "$name")
96+
log_message "Successfully created and started container $name with network $networks" "SUCCESS"
97+
log_message "Container details - $details" "INFO"
98+
else
99+
log_message "Failed to create container $name with network $networks" "ERROR"
100+
fi
96101
fi
97102
;;
98103
esac
99104
done < <(reverse_file "$SHUTDOWN_LIST")
100105

101-
log_message "Finished starting all containers from shutdown list."
106+
log_message "Container startup process completed" "INFO"

0 commit comments

Comments
 (0)