Add background-upgrade service for online schema migrations #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Publish Docker Images | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| tags: | |
| - 'release-*' | |
| pull_request: | |
| branches: | |
| - master | |
| - main | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ghcr.io/${{ github.repository_owner }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| component: [agent, server, server-e2e, web] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from build.properties | |
| id: version | |
| run: | | |
| NETXMS_VERSION=$(grep '^NETXMS_VERSION=' build.properties | cut -d= -f2) | |
| NETXMS_PACKAGE_VERSION=$(grep '^NETXMS_PACKAGE_VERSION=' build.properties | cut -d= -f2) | |
| echo "netxms_version=${NETXMS_VERSION}" >> $GITHUB_OUTPUT | |
| echo "package_version=${NETXMS_PACKAGE_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Generate metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.IMAGE_PREFIX }}/${{ matrix.component }} | |
| tags: | | |
| type=semver,pattern={{version}},value=${{ github.ref_name }},prefix=release-,enable=${{ startsWith(github.ref, 'refs/tags/release-') }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }},prefix=release-,enable=${{ startsWith(github.ref, 'refs/tags/release-') }} | |
| type=raw,value=${{ steps.version.outputs.netxms_version }},enable=${{ startsWith(github.ref, 'refs/tags/release-') }} | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Download NetXMS web archive | |
| if: matrix.component == 'web' | |
| run: | | |
| VERSION=${{ steps.version.outputs.netxms_version }} | |
| if [ ! -f web/nxmc-${VERSION}.war ]; then | |
| curl -L -o web/nxmc-${VERSION}.war https://netxms.org/download/releases/$(echo ${VERSION} | cut -d. -f1-2)/nxmc-${VERSION}.war | |
| fi | |
| - name: Create package pin file | |
| if: matrix.component != 'web' | |
| run: | | |
| ./pin-package-version ${{ matrix.component }}/files/netxms-pin ${{ steps.version.outputs.package_version }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./${{ matrix.component }} | |
| platforms: ${{ matrix.component == 'web' && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| NETXMS_VERSION=${{ steps.version.outputs.netxms_version }} | |
| NETXMS_PACKAGE_VERSION=${{ steps.version.outputs.package_version }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Clean up pin file | |
| if: matrix.component != 'web' && always() | |
| run: | | |
| rm -f ${{ matrix.component }}/files/netxms-pin | |
| test-deployment: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from build.properties | |
| id: version | |
| run: | | |
| NETXMS_VERSION=$(grep '^NETXMS_VERSION=' build.properties | cut -d= -f2) | |
| echo "netxms_version=${NETXMS_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Test deployment | |
| run: | | |
| cd deployment-example | |
| # Create test environment file | |
| cat > .env << EOF | |
| NETXMS_VERSION=${{ steps.version.outputs.netxms_version }} | |
| POSTGRES_DB=netxms | |
| POSTGRES_USER=netxms | |
| POSTGRES_PASSWORD=test_password | |
| EOF | |
| # Use locally built images for testing | |
| export IMAGE_PREFIX=${{ env.IMAGE_PREFIX }} | |
| # Start services | |
| docker compose up -d db | |
| # Wait for database to be ready | |
| sleep 30 | |
| # Initialize database | |
| docker compose run --rm init | |
| # Start remaining services | |
| docker compose up -d | |
| # Wait for services to start | |
| sleep 60 | |
| # Check services are running | |
| docker compose ps | |
| # Basic connectivity test | |
| docker compose exec -T server nxdbmgr get DBLockStatus || true | |
| # Cleanup | |
| docker compose down -v | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: startsWith(github.ref, 'refs/tags/release-') | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Extract version from build.properties | |
| id: version | |
| run: | | |
| NETXMS_VERSION=$(grep '^NETXMS_VERSION=' build.properties | cut -d= -f2) | |
| echo "netxms_version=${NETXMS_VERSION}" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| name: NetXMS Docker ${{ steps.version.outputs.netxms_version }} | |
| body: | | |
| Docker images for NetXMS ${{ steps.version.outputs.netxms_version }} | |
| ## Images | |
| - `${{ env.IMAGE_PREFIX }}/agent:${{ steps.version.outputs.netxms_version }}` | |
| - `${{ env.IMAGE_PREFIX }}/server:${{ steps.version.outputs.netxms_version }}` | |
| - `${{ env.IMAGE_PREFIX }}/server-e2e:${{ steps.version.outputs.netxms_version }}` | |
| - `${{ env.IMAGE_PREFIX }}/web:${{ steps.version.outputs.netxms_version }}` | |
| ## Usage | |
| ```bash | |
| cd deployment-example | |
| NETXMS_VERSION=${{ steps.version.outputs.netxms_version }} docker compose up -d | |
| ``` | |
| draft: false | |
| prerelease: false |