- Introduced `certbot.py` for ACME certificate management, including certificate issuance, renewal, and environment validation. - Added `haproxy.py` for HAProxy process management, configuration validation, and dynamic command handling. - Implemented `container_env.py` for reading and parsing environment variables with YAML overrides. - Created `consts.py` for centralized management of static and dynamic paths. - Added `manager.py` to enable plugin discovery, initialization, configuration, and execution. - Refactored logging and configuration handling across modules for consistency. Enhances modularity and scalability by introducing feature-dedicated modules and structured configuration handling.
301 lines
No EOL
8.4 KiB
YAML
301 lines
No EOL
8.4 KiB
YAML
name: Docker
|
|
|
|
on:
|
|
# schedule:
|
|
# - cron: '0 10 1 * *'
|
|
push:
|
|
branches: [ master ]
|
|
# Publish semver tags as releases.
|
|
tags: [ '*.*.*' ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
workflow_dispatch: # Allow manual trigger
|
|
inputs:
|
|
push:
|
|
description: 'Push image to registry'
|
|
required: false
|
|
default: 'false'
|
|
type: choice
|
|
options:
|
|
- 'false'
|
|
- 'true'
|
|
|
|
env:
|
|
# github.repository as <account>/<repo>
|
|
IMAGE_NAME: byjg/easy-haproxy
|
|
|
|
|
|
jobs:
|
|
Test:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv sync --group dev
|
|
|
|
- name: Run tests
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv run pytest -s tests/ -vv
|
|
|
|
Tests-E2E-Docker:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
needs: [Test]
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv sync --group dev
|
|
|
|
- name: Run Docker Compose E2E tests
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv run pytest tests_e2e/test_docker_compose.py -sv --tb=short
|
|
|
|
Tests-E2E-Kubernetes:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
needs: [Test]
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv sync --group dev
|
|
|
|
- name: Run Kubernetes E2E tests
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv run pytest tests_e2e/test_kubernetes.py -sv --tb=short
|
|
|
|
Tests-E2E-Additional:
|
|
runs-on: ubuntu-latest
|
|
needs: [Test]
|
|
timeout-minutes: 20
|
|
permissions:
|
|
contents: read
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv sync --group dev
|
|
|
|
- name: Clean Docker build cache
|
|
run: docker builder prune -af
|
|
|
|
- name: Run Static E2E tests
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv run pytest tests_e2e/test_static.py -sv --tb=short
|
|
|
|
- name: Run Proxy Headers E2E tests
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv run pytest tests_e2e/test_proxy_headers.py -sv --tb=short
|
|
|
|
Build:
|
|
runs-on: ubuntu-latest
|
|
needs: [Test, Tests-E2E-Docker, Tests-E2E-Kubernetes, Tests-E2E-Additional]
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log into registry
|
|
if: github.event_name == 'push' || github.event.inputs.push == 'true'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.DOCKER_REGISTRY }}
|
|
username: ${{ secrets.DOCKER_REGISTRY_USER }}
|
|
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
|
|
|
|
# Extract metadata (tags, labels) for Docker
|
|
# https://github.com/docker/metadata-action
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ secrets.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
|
|
- uses: actions/github-script@v6
|
|
id: tags
|
|
with:
|
|
script: |
|
|
tags = `${{ join(steps.meta.outputs.tags, ',') }}`
|
|
result = []
|
|
tags.split("\n").forEach(function (item) {
|
|
short_tag = item.trim().split(":")[1];
|
|
if (short_tag == "master" || short_tag == "main") {
|
|
result.push("latest");
|
|
} else if (short_tag != "latest") {
|
|
result.push(short_tag);
|
|
}
|
|
})
|
|
return result.join(",");
|
|
result-encoding: string
|
|
|
|
- name: Get Tags
|
|
run: |
|
|
echo "${{ steps.tags.outputs.result }}"
|
|
|
|
- uses: actions/github-script@v6
|
|
id: normalized
|
|
with:
|
|
script: |
|
|
tags = `${{ join(steps.meta.outputs.tags, ',') }}`
|
|
result = []
|
|
tags.split("\n").forEach(function (item) {
|
|
short_tag = item.trim().split(":")[1];
|
|
if (short_tag == "master" || short_tag == "main") {
|
|
result.push("${{ env.IMAGE_NAME }}:latest");
|
|
} else if (short_tag != "latest") {
|
|
result.push("${{ env.IMAGE_NAME }}:" + short_tag);
|
|
}
|
|
})
|
|
return result.join(",");
|
|
result-encoding: string
|
|
|
|
- name: Get Normalized Docker Image
|
|
run: |
|
|
echo "${{ steps.normalized.outputs.result }}"
|
|
|
|
# Build and push Docker image with Buildx (don't push on PR)
|
|
# https://github.com/docker/build-push-action
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: deploy/docker/Dockerfile
|
|
build-args: |
|
|
RELEASE_VERSION_ARG="${{ steps.tags.outputs.result }}"
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name == 'push' || github.event.inputs.push == 'true' }}
|
|
tags: ${{ steps.normalized.outputs.result }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
outputs:
|
|
tags: "${{ steps.tags.outputs.result }}"
|
|
|
|
|
|
# - name: Docker Hub Description
|
|
# if: github.event_name == 'push' || github.event.inputs.push == 'true'
|
|
# run: |
|
|
# wget -q https://github.com/christian-korneck/docker-pushrm/releases/download/v1.8.0/docker-pushrm_linux_amd64 -O $HOME/.docker/cli-plugins/docker-pushrm
|
|
# chmod +x $HOME/.docker/cli-plugins/docker-pushrm
|
|
# docker pushrm ${{ env.IMAGE_NAME }}
|
|
|
|
Publish-PyPI:
|
|
runs-on: ubuntu-latest
|
|
needs: [Test, Tests-E2E-Docker, Tests-E2E-Kubernetes, Tests-E2E-Additional]
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
permissions:
|
|
contents: read
|
|
id-token: write # Required for OIDC trusted publisher
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
- name: Build package
|
|
run: |
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
uv build
|
|
|
|
- name: Publish to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
|
|
Helm:
|
|
runs-on: 'ubuntu-latest'
|
|
needs: Build
|
|
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')
|
|
env:
|
|
DOC_GITHUB_TOKEN: '${{ secrets.DOC_TOKEN }}'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
with:
|
|
ref: master
|
|
|
|
- uses: actions/checkout@v4
|
|
if: github.ref == 'refs/heads/master'
|
|
|
|
- name: Get result
|
|
run: echo "${{ needs.Build.outputs.tags }}"
|
|
|
|
- name: Verify versions are pre-bumped
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
run: |
|
|
TAG="${{ needs.Build.outputs.tags }}"
|
|
if [ "$TAG" = "latest" ]; then
|
|
echo "Skipping latest tag verification"
|
|
exit 0
|
|
fi
|
|
./scripts/bump-version.sh --verify "$TAG"
|
|
|
|
HelmDeploy:
|
|
if: github.ref == 'refs/heads/master'
|
|
needs: Helm
|
|
uses: byjg/byjg.github.io/.github/workflows/add-helm.yaml@master
|
|
with:
|
|
repo: ${{ github.event.repository.name }}
|
|
folder: helm
|
|
project: easyhaproxy
|
|
secrets: inherit
|
|
|
|
Documentation:
|
|
if: github.ref == 'refs/heads/master'
|
|
needs: HelmDeploy
|
|
uses: byjg/byjg.github.io/.github/workflows/add-doc.yaml@master
|
|
with:
|
|
folder: devops
|
|
project: ${{ github.event.repository.name }}
|
|
secrets:
|
|
DOC_TOKEN: ${{ secrets.DOC_TOKEN }} |