Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: CI

on:
push:
branches: [ feature/* ]
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
Expand All @@ -22,8 +22,11 @@ jobs:
- name: Install Dependencies
run: go mod tidy

- name: Build Binary
run: go build -o monitor
- name: Build and Install Monitor
run: |
go build -o monitor
sudo mv monitor /usr/local/bin/
chmod +x /usr/local/bin/monitor

- name: Install Docker and Docker Compose
run: |
Expand All @@ -43,11 +46,23 @@ jobs:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


- name: Start Docker Containers for Testing
- name: Set Up SSH Config for CI
run: |
mkdir -p ~/.ssh
echo "Host localhost" >> ~/.ssh/config
echo " HostName localhost" >> ~/.ssh/config
echo " User root" >> ~/.ssh/config
echo " IdentityFile /tmp/ci_ssh_key" >> ~/.ssh/config
chmod 600 ~/.ssh/config
ssh-keygen -t rsa -b 2048 -f /tmp/ci_ssh_key -q -N ""
cat /tmp/ci_ssh_key.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh-keyscan localhost >> ~/.ssh/known_hosts

- name: Start Local Docker Containers for Testing
run: docker compose -f docker-compose.yml up -d

- name: Wait for Containers to Initialize
- name: Wait for Local Containers to Initialize
run: sleep 10 # Ensure services are fully started

- name: Run Installation Script
Expand All @@ -62,6 +77,5 @@ jobs:
echo "🔄 Testing monitor --state"
monitor state || { echo "❌ monitor state failed"; exit 1; }


- name: Stop and Clean Up Docker Containers
run: docker compose down
48 changes: 32 additions & 16 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI/CD

on:
pull_request:
push:
branches: [ main ]
workflow_dispatch:

Expand All @@ -22,8 +22,11 @@ jobs:
- name: Install Dependencies
run: go mod tidy

- name: Build Binary
run: go build -o monitor
- name: Build and Install Monitor
run: |
go build -o monitor
sudo mv monitor /usr/local/bin/
chmod +x /usr/local/bin/monitor

- name: Install Docker and Docker Compose
run: |
Expand All @@ -43,55 +46,68 @@ jobs:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin


- name: Start Docker Containers for Testing
- name: Set Up SSH Config for CI
run: |
mkdir -p ~/.ssh
echo "Host localhost" >> ~/.ssh/config
echo " HostName localhost" >> ~/.ssh/config
echo " User root" >> ~/.ssh/config
echo " IdentityFile /tmp/ci_ssh_key" >> ~/.ssh/config
chmod 600 ~/.ssh/config
ssh-keygen -t rsa -b 2048 -f /tmp/ci_ssh_key -q -N ""
cat /tmp/ci_ssh_key.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
ssh-keyscan localhost >> ~/.ssh/known_hosts

- name: Start Local Docker Containers for Testing
run: docker compose -f docker-compose.yml up -d

- name: Wait for Containers to Initialize
- name: Wait for Local Containers to Initialize
run: sleep 10 # Ensure services are fully started

- name: Run Installation Script
run: |
python3 install.py

- name: Stop and Clean Up Docker Containers
run: docker compose down

- name: Verify Monitor Commands
run: |
echo "🔄 Testing monitor --service"
monitor --service || { echo "❌ monitor --service failed"; exit 1; }
monitor service || { echo "❌ monitor service failed"; exit 1; }

echo "🔄 Testing monitor --state"
monitor --state || { echo "❌ monitor --state failed"; exit 1; }
monitor state || { echo "❌ monitor state failed"; exit 1; }

- name: Stop and Clean Up Docker Containers
run: docker compose down

- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: monitor-binary
path: monitor
path: /usr/local/bin/monitor

release:
name: Create GitHub Release
needs: build
runs-on: ubuntu-latest
# Release tylko przy pushu do main
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Download Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: monitor-binary

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/heads/main'
with:
tag_name: v1.0.${{ github.run_number }}
name: "Release v1.0.${{ github.run_number }}"
body: "Automated release for GO Container Monitor"
files: monitor
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.MONITOR_TOKEN_CICD }}
Loading