Add simplified workflow test
This commit is contained in:
20
.gitea/workflows/build-simple.yaml
Normal file
20
.gitea/workflows/build-simple.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Zabbix Build Test
|
||||||
|
run-name: ${{ gitea.actor }} is testing Zabbix build 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-zabbix-build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||||
|
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||||
|
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||||
|
- name: List files in the repository
|
||||||
|
run: |
|
||||||
|
ls ${{ gitea.workspace }}
|
||||||
|
echo "Checking zabbix-apk-builder directory:"
|
||||||
|
ls ${{ gitea.workspace }}/zabbix-apk-builder/
|
||||||
|
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
name: Zabbix APK Builder
|
name: Zabbix APK Builder
|
||||||
|
run-name: ${{ gitea.actor }} is building Zabbix APK packages 🚀
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Manual trigger
|
# Manual trigger
|
||||||
@@ -10,14 +11,10 @@ on:
|
|||||||
default: 'false'
|
default: 'false'
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
||||||
# Scheduled check for new versions (daily at 6 AM UTC)
|
|
||||||
schedule:
|
|
||||||
- cron: '0 6 * * *'
|
|
||||||
|
|
||||||
# Trigger on pushes to main/test branch
|
# Trigger on pushes to main/test branch
|
||||||
push:
|
push:
|
||||||
branches: [ main, test ]
|
branches: [ main, test ]
|
||||||
paths: [ 'zabbix-apk-builder/APKBUILD', 'zabbix-apk-builder/Dockerfile', 'zabbix-apk-builder/build.sh', 'zabbix-apk-builder/*.initd', 'zabbix-apk-builder/*.confd' ]
|
paths: [ 'zabbix-apk-builder/**' ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Simple test job to verify workflow triggers
|
# Simple test job to verify workflow triggers
|
||||||
@@ -27,204 +24,12 @@ jobs:
|
|||||||
- name: Test workflow trigger
|
- name: Test workflow trigger
|
||||||
run: |
|
run: |
|
||||||
echo "🎉 Build workflow was triggered!"
|
echo "🎉 Build workflow was triggered!"
|
||||||
echo "Event: ${{ github.event_name }}"
|
echo "Event: ${{ gitea.event_name }}"
|
||||||
echo "Branch: ${{ github.ref }}"
|
echo "Branch: ${{ gitea.ref }}"
|
||||||
echo "Repository: ${{ github.repository }}"
|
echo "Repository: ${{ gitea.repository }}"
|
||||||
|
- name: Check out repository code
|
||||||
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
|
uses: actions/checkout@v4
|
||||||
with:
|
- name: List files in the repository
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Check for new Zabbix version
|
|
||||||
id: version-check
|
|
||||||
run: |
|
run: |
|
||||||
# Install jq for JSON parsing
|
ls ${{ gitea.workspace }}
|
||||||
sudo apt-get update && sudo apt-get install -y jq
|
ls ${{ gitea.workspace }}/zabbix-apk-builder/
|
||||||
|
|
||||||
# Get current version from APKBUILD (correct path)
|
|
||||||
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 Bitbucket 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" ] || [ "${{ inputs.force_build }}" = "true" ]; then
|
|
||||||
echo "should_build=true" >> $GITHUB_OUTPUT
|
|
||||||
echo "Build required: Version changed or force build requested"
|
|
||||||
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.GITEA_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Update APKBUILD version
|
|
||||||
run: |
|
|
||||||
LATEST_VERSION="${{ needs.check-version.outputs.latest_version }}"
|
|
||||||
CURRENT_VERSION="${{ needs.check-version.outputs.current_version }}"
|
|
||||||
|
|
||||||
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
|
|
||||||
echo "Updating APKBUILD from $CURRENT_VERSION to $LATEST_VERSION"
|
|
||||||
|
|
||||||
# Update pkgver (correct path)
|
|
||||||
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 "Update Zabbix to version $LATEST_VERSION" || exit 0
|
|
||||||
git push
|
|
||||||
fi
|
|
||||||
|
|
||||||
build-packages:
|
|
||||||
needs: [check-version]
|
|
||||||
if: needs.check-version.outputs.should_build == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
token: ${{ secrets.GITEA_TOKEN }}
|
|
||||||
fetch-depth: 0
|
|
||||||
# Pull latest changes in case version was updated
|
|
||||||
ref: ${{ github.ref }}
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Build Zabbix packages
|
|
||||||
run: |
|
|
||||||
cd zabbix-apk-builder
|
|
||||||
chmod +x build.sh
|
|
||||||
./build.sh
|
|
||||||
|
|
||||||
- name: List built packages
|
|
||||||
run: |
|
|
||||||
echo "Built packages:"
|
|
||||||
ls -la zabbix-apk-builder/packages/
|
|
||||||
|
|
||||||
echo "Package sizes:"
|
|
||||||
du -h zabbix-apk-builder/packages/*.apk
|
|
||||||
|
|
||||||
- name: Upload packages as artifacts
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: zabbix-apk-packages
|
|
||||||
path: zabbix-apk-builder/packages/*.apk
|
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
publish-to-gitea:
|
|
||||||
needs: [check-version, build-packages]
|
|
||||||
if: needs.check-version.outputs.should_build == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download packages
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: zabbix-apk-packages
|
|
||||||
path: packages/
|
|
||||||
|
|
||||||
- name: Setup SSH for Gitea
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "${{ secrets.GITEA_SSH_KEY }}" > ~/.ssh/id_rsa
|
|
||||||
chmod 600 ~/.ssh/id_rsa
|
|
||||||
# Add your Gitea server to known_hosts - replace with your actual Gitea server hostname
|
|
||||||
ssh-keyscan -H gitea-repo >> ~/.ssh/known_hosts 2>/dev/null || echo "gitea-repo ssh-rsa YOUR_HOST_KEY" >> ~/.ssh/known_hosts
|
|
||||||
|
|
||||||
- name: Publish to Gitea repository
|
|
||||||
run: |
|
|
||||||
# Clone or update the packages repository
|
|
||||||
git clone git@gitea-repo:mbuz/Zabbix.git gitea-repo || true
|
|
||||||
cd gitea-repo
|
|
||||||
|
|
||||||
# Create packages directory structure
|
|
||||||
mkdir -p alpine/v3.18/main/x86_64
|
|
||||||
|
|
||||||
# Copy new packages
|
|
||||||
cp ../packages/*.apk alpine/v3.18/main/x86_64/
|
|
||||||
|
|
||||||
# Update package index (simplified)
|
|
||||||
cd alpine/v3.18/main/x86_64
|
|
||||||
ls *.apk > PACKAGES.txt
|
|
||||||
|
|
||||||
# Commit and push
|
|
||||||
git config --local user.email "action@gitea.com"
|
|
||||||
git config --local user.name "Gitea Action"
|
|
||||||
git add .
|
|
||||||
git commit -m "Add Zabbix ${{ needs.check-version.outputs.latest_version }} packages" || exit 0
|
|
||||||
git push
|
|
||||||
|
|
||||||
deploy-test:
|
|
||||||
needs: [check-version, build-packages]
|
|
||||||
if: needs.check-version.outputs.should_build == 'true' && github.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: |
|
|
||||||
# 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
|
|
||||||
"
|
|
||||||
|
|
||||||
# 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 "✅ Package deployment test passed"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user