167 lines
5.2 KiB
YAML
167 lines
5.2 KiB
YAML
name: Zabbix APK Builder
|
|
|
|
on:
|
|
# Trigger on pushes to main/test branch
|
|
push:
|
|
branches: [ main, test ]
|
|
paths: [ 'zabbix-apk-builder/**' ]
|
|
if: "!contains(gitea.event.head_commit.message, '[ci skip]')"
|
|
|
|
# Scheduled check for new versions (daily at 6 AM UTC)
|
|
schedule:
|
|
- cron: '0 6 * * *'
|
|
|
|
jobs:
|
|
check-version:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should_build: ${{ steps.version-check.outputs.should_build }}
|
|
latest_version: ${{ steps.version-check.outputs.latest_version }}
|
|
current_version: ${{ steps.version-check.outputs.current_version }}
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Check for new Zabbix version
|
|
id: version-check
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
# Install jq for JSON parsing
|
|
sudo apt-get update && sudo apt-get install -y jq
|
|
|
|
# Get current version from APKBUILD
|
|
CURRENT_VERSION=$(grep '^pkgver=' zabbix-apk-builder/APKBUILD | cut -d'=' -f2)
|
|
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
echo "Current version: $CURRENT_VERSION"
|
|
|
|
# Get latest version from Zabbix API (stable releases only)
|
|
LATEST_VERSION=$(curl -s "https://git.zabbix.com/rest/api/1.0/projects/ZBX/repos/zabbix/tags?limit=100" | \
|
|
jq -r '.values[].displayId' | \
|
|
grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | \
|
|
grep -v 'rc\|beta\|alpha' | \
|
|
sort -V | \
|
|
tail -1)
|
|
|
|
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
|
|
echo "Latest version: $LATEST_VERSION"
|
|
|
|
# Determine if we should build
|
|
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
|
|
echo "should_build=true" >> $GITHUB_OUTPUT
|
|
echo "Build required: Version changed"
|
|
else
|
|
echo "should_build=false" >> $GITHUB_OUTPUT
|
|
echo "No build required: Version unchanged"
|
|
fi
|
|
|
|
update-version:
|
|
needs: [check-version]
|
|
if: needs.check-version.outputs.should_build == 'true' && needs.check-version.outputs.current_version != needs.check-version.outputs.latest_version
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.ACCESS_TOKEN }}
|
|
|
|
- name: Update APKBUILD version
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
LATEST_VERSION="${{ needs.check-version.outputs.latest_version }}"
|
|
CURRENT_VERSION="${{ needs.check-version.outputs.current_version }}"
|
|
|
|
echo "Updating APKBUILD from $CURRENT_VERSION to $LATEST_VERSION"
|
|
|
|
# Update pkgver
|
|
sed -i "s/^pkgver=.*/pkgver=$LATEST_VERSION/" zabbix-apk-builder/APKBUILD
|
|
|
|
# Reset pkgrel to 0 for new version
|
|
sed -i "s/^pkgrel=.*/pkgrel=0/" zabbix-apk-builder/APKBUILD
|
|
|
|
# Clear checksums (will be regenerated during build)
|
|
sed -i 's/^sha512sums=.*/sha512sums="SKIP"/' zabbix-apk-builder/APKBUILD
|
|
|
|
# Commit changes
|
|
git config --local user.email "action@gitea.com"
|
|
git config --local user.name "Gitea Action"
|
|
git add zabbix-apk-builder/APKBUILD
|
|
git commit -m "CHANGE: Update Zabbix to version $LATEST_VERSION [ci skip]" || exit 0
|
|
git push
|
|
|
|
build-packages:
|
|
needs: [update-version]
|
|
if: needs.check-version.outputs.should_build == 'true'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ gitea.head_ref }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build Zabbix packages
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
cd zabbix-apk-builder
|
|
chmod +x build.sh
|
|
./build.sh
|
|
|
|
- name: List built packages
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
echo "Built packages:"
|
|
ls -la zabbix-apk-builder/packages/
|
|
|
|
echo "Package sizes:"
|
|
du -h zabbix-apk-builder/packages/*.apk || echo "No packages found"
|
|
|
|
- name: Upload packages as artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: zabbix-apk-packages
|
|
path: zabbix-apk-builder/packages/*.apk
|
|
retention-days: 30
|
|
|
|
deploy-test:
|
|
needs: [build-packages]
|
|
if: needs.check-version.outputs.should_build == 'true' && gitea.ref == 'refs/heads/test'
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Download packages
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: zabbix-apk-packages
|
|
path: packages/
|
|
|
|
- name: Test deployment in Alpine container
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
echo "Testing package installation..."
|
|
|
|
# Test agent package
|
|
docker run --rm -v $PWD/packages:/packages alpine:latest sh -c "
|
|
apk add --allow-untrusted /packages/zabbix-agent-*.apk
|
|
which zabbix_agentd
|
|
zabbix_agentd --version
|
|
" || echo "Agent test failed"
|
|
|
|
# Test proxy package
|
|
docker run --rm -v $PWD/packages:/packages alpine:latest sh -c "
|
|
apk add --allow-untrusted /packages/zabbix-proxy-*.apk
|
|
which zabbix_proxy
|
|
zabbix_proxy --version
|
|
" || echo "Proxy test failed"
|
|
|
|
echo "✅ Package deployment test completed"
|