Skip to content

Commit 5ea6445

Browse files
committed
update the gitaction to folder based running
1 parent 052797e commit 5ea6445

File tree

1 file changed

+117
-83
lines changed

1 file changed

+117
-83
lines changed

.github/workflows/main.yaml

Lines changed: 117 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,128 @@
1-
name: Run Podman Compose (Build & Deploy)
1+
name: Run Podman Compose demos
22

33
on:
44
push:
55
branches: [ main ]
6+
paths:
7+
- '.github/workflows/**'
8+
- 'demo/demo-1-basics/**'
9+
- 'demo/demo-2-otel/**'
610
pull_request:
11+
paths:
12+
- '.github/workflows/**'
13+
- 'demo/demo-1-basics/**'
14+
- 'demo/demo-2-otel/**'
15+
workflow_dispatch:
716

817
jobs:
918
podman-compose:
1019
runs-on: ubuntu-latest
1120

21+
env:
22+
XDG_RUNTIME_DIR: ${{ github.workspace }}/podman-runtime
23+
TMPDIR: ${{ github.workspace }}/podman-tmp
24+
PODMAN_STORAGE: ${{ github.workspace }}/podman-storage
25+
1226
steps:
13-
# Step 1: Checkout repository
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
17-
# Step 2: Install Podman & podman-compose
18-
- name: Install Podman
19-
run: |
20-
sudo apt-get update -y
21-
sudo apt-get install -y podman python3-pip
22-
pip install podman-compose
23-
podman --version
24-
25-
# Step 3: Configure Podman storage correctly
26-
- name: Configure Podman storage
27-
run: |
28-
STORAGE_ROOT="/home/runner/work/_containers"
29-
sudo mkdir -p $STORAGE_ROOT
30-
sudo mkdir -p /etc/containers
31-
32-
echo "[storage]" | sudo tee /etc/containers/storage.conf
33-
echo "graphroot=\"$STORAGE_ROOT\"" | sudo tee -a /etc/containers/storage.conf
34-
35-
podman system migrate
36-
37-
# Step 4: Ensure Podman network exists
38-
- name: Ensure Podman network
39-
run: |
40-
NETWORK_NAME="edge-network"
41-
if ! podman network exists "$NETWORK_NAME"; then
42-
podman network create "$NETWORK_NAME"
43-
fi
44-
45-
# Step 5: Build images (docker-compose.yml)
46-
- name: Build Podman images
47-
working-directory: demo/demo-2-otel
48-
run: |
49-
echo "Building images..."
50-
podman-compose -f docker-compose.yml build
51-
echo "Build completed."
52-
53-
# Step 6: Run first compose - core stack
54-
- name: Run Podman Compose (Core services)
55-
working-directory: demo/demo-2-otel
56-
run: |
57-
echo "Starting core services (docker-compose.yml)..."
58-
podman-compose -f docker-compose.yml up -d
59-
podman ps
60-
61-
# Step 7: Run second compose - persistence stack
62-
- name: Run Podman Compose (Persistence services)
63-
working-directory: demo/demo-2-otel
64-
run: |
65-
echo "Starting persistence services (docker-compose-persistance.yml)..."
66-
podman-compose -f docker-compose-persistance.yml up -d
67-
podman ps
68-
69-
# Step 8: Show Podman environment
70-
- name: Verify Podman environment
71-
run: |
72-
podman network ls
73-
podman ps -a
74-
75-
# Step 9: Show logs for each container
76-
- name: Show Container Logs
77-
working-directory: demo/demo-2-otel
78-
run: |
79-
echo "Displaying logs for all containers..."
80-
podman ps --format "{{.Names}}" | while read -r c; do
81-
echo "----------------------------"
82-
echo "Logs for: $c"
83-
echo "----------------------------"
84-
podman logs "$c" || echo "No logs for $c"
85-
done
86-
87-
# Step 10: Cleanup always
88-
- name: Stop and Clean Up
89-
if: always()
90-
working-directory: demo/demo-2-otel
91-
run: |
92-
podman-compose -f docker-compose.yml down
93-
podman-compose -f docker-compose-persistance.yml down
94-
echo "Cleanup completed."
27+
# --------------------------------------------------
28+
# 1️⃣ Checkout
29+
# --------------------------------------------------
30+
- uses: actions/checkout@v4
31+
32+
# --------------------------------------------------
33+
# 2️⃣ Free disk space
34+
# --------------------------------------------------
35+
- name: Free disk space
36+
run: |
37+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
38+
sudo docker image prune -a -f || true
39+
df -h
40+
41+
# --------------------------------------------------
42+
# 3️⃣ Install Podman
43+
# --------------------------------------------------
44+
- name: Install Podman & podman-compose
45+
run: |
46+
sudo apt-get update -y
47+
sudo apt-get install -y podman uidmap python3-pip
48+
pip install podman-compose
49+
50+
# --------------------------------------------------
51+
# 4️⃣ Silence Podman warnings
52+
# --------------------------------------------------
53+
- name: Configure Podman runtime
54+
run: |
55+
mkdir -p ~/.config/containers
56+
cat <<EOF > ~/.config/containers/containers.conf
57+
[engine]
58+
cgroup_manager = "cgroupfs"
59+
runtime = "crun"
60+
events_logger = "file"
61+
systemd = false
62+
log_level = "error"
63+
EOF
64+
65+
# --------------------------------------------------
66+
# 5️⃣ Storage
67+
# --------------------------------------------------
68+
- name: Configure Podman storage
69+
run: |
70+
mkdir -p "$XDG_RUNTIME_DIR" "$TMPDIR" "$PODMAN_STORAGE"
71+
chmod 700 "$XDG_RUNTIME_DIR"
72+
chmod 777 "$TMPDIR" "$PODMAN_STORAGE"
73+
74+
cat <<EOF > ~/.config/containers/storage.conf
75+
[storage]
76+
driver = "overlay"
77+
graphroot = "$PODMAN_STORAGE"
78+
runroot = "$XDG_RUNTIME_DIR/runroot"
79+
EOF
80+
81+
podman system migrate
82+
83+
# --------------------------------------------------
84+
# 6️⃣ Hard cleanup
85+
# --------------------------------------------------
86+
- name: Cleanup
87+
run: podman system prune -a -f
88+
89+
# ==================================================
90+
# 🔹 DEMO 1 — BASICS
91+
# ==================================================
92+
- name: Create anomaly-network
93+
run: podman network create anomaly-network || true
94+
95+
- name: Run demo-1-basics
96+
working-directory: demo/demo-1-basics
97+
run: |
98+
podman-compose build --no-cache 2>/dev/null
99+
podman-compose up -d 2>/dev/null
100+
101+
echo "✅ demo-1-basics running containers:"
102+
podman ps --format "table {{.Names}}\t{{.Status}}"
103+
104+
podman-compose down -v 2>/dev/null
105+
106+
- run: podman system prune -a -f
107+
108+
# ==================================================
109+
# 🔹 DEMO 2 — OTEL
110+
# ==================================================
111+
- name: Create edge-network
112+
run: podman network create edge-network || true
113+
114+
- name: Run demo-2-otel
115+
working-directory: demo/demo-2-otel
116+
run: |
117+
podman-compose build --no-cache 2>/dev/null
118+
podman-compose up -d 2>/dev/null
119+
120+
echo "✅ demo-2-otel running containers:"
121+
podman ps --format "table {{.Names}}\t{{.Status}}"
122+
123+
# --------------------------------------------------
124+
# 7️⃣ Final cleanup
125+
# --------------------------------------------------
126+
- name: Final cleanup
127+
if: always()
128+
run: podman system prune -a -f

0 commit comments

Comments
 (0)