Skip to content

Commit 5f75bd3

Browse files
committed
git actions added to build and run podman compose
1 parent 97662a6 commit 5f75bd3

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/main.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Run Podman Compose (Build & Deploy)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
podman-compose:
11+
# Use this for GitHub-hosted runners
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Step 1: Checkout repository
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
# Step 2: Free up disk space on GitHub runner
20+
- name: Free up disk space
21+
run: |
22+
echo " Cleaning up disk space..."
23+
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true
24+
sudo apt-get clean
25+
df -h
26+
27+
# Step 3: Install Podman and podman-compose
28+
- name: Install Podman
29+
run: |
30+
sudo apt-get update -y
31+
sudo apt-get install -y podman python3-pip
32+
pip install podman-compose
33+
podman --version
34+
podman-compose --version
35+
36+
# Step 4: Configure Podman storage to use a larger path
37+
- name: Configure Podman storage
38+
run: |
39+
echo " Reconfiguring Podman storage to use /home/runner/work/_containers"
40+
sudo mkdir -p /home/runner/work/_containers
41+
sudo bash -c 'echo "graphroot=\"/home/runner/work/_containers\"" >> /etc/containers/storage.conf'
42+
df -h
43+
44+
# Step 5: Ensure Podman network exists
45+
- name: Ensure network exists
46+
run: |
47+
NETWORK_NAME="anomaly-network"
48+
if ! podman network exists "$NETWORK_NAME"; then
49+
echo "Creating network $NETWORK_NAME"
50+
podman network create "$NETWORK_NAME"
51+
else
52+
echo "Network $NETWORK_NAME already exists"
53+
fi
54+
55+
# Step 6: Build Podman images
56+
- name: Build Podman images
57+
working-directory: demo
58+
run: |
59+
echo " Building images..."
60+
podman-compose -f docker-compose.yaml build
61+
echo " Build completed."
62+
63+
# Step 7: Run containers
64+
- name: Run Podman Compose
65+
working-directory: demo
66+
run: |
67+
echo " Starting containers..."
68+
podman-compose -f docker-compose.yaml up -d
69+
echo " Containers started."
70+
echo " Running containers:"
71+
podman ps
72+
73+
# Step 8: Verify network and container health
74+
- name: Verify Podman environment
75+
run: |
76+
echo " Networks:"
77+
podman network ls
78+
echo " Containers:"
79+
podman ps -a
80+
81+
# Step 9: Stop and clean up containers (always runs)
82+
- name: Stop and Clean Up
83+
if: always()
84+
working-directory: demo
85+
run: |
86+
echo "Cleaning up..."
87+
podman-compose -f docker-compose.yaml down
88+
echo "Cleanup completed."

0 commit comments

Comments
 (0)