Skip to content

sip: support TLS listeners and transport telemetry #617

sip: support TLS listeners and transport telemetry

sip: support TLS listeners and transport telemetry #617

name: Build and Publish Docker Image
on:
push:
branches:
- master
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Image tag (e.g., rc1, latest)'
required: true
default: 'latest'
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
# Don't let overlapping pushes race (also avoids the binfmt cache-reserve warning and
# saves CI minutes): a newer run cancels an in-progress one for the same ref.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.12'
cache: 'pip'
- name: Run unit tests
run: |
pip install pytest redis asyncssh phonenumbers
python -m pytest tests/test_unit.py -v --tb=short
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
with:
cache-image: false # skip binfmt GHA cache (avoids the cache-reserve warning)
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# master push or version tag → latest
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v') }}
# v1.2.3 tag push → 1.2.3 (also gets latest from above via ref)
type=semver,pattern={{version}}
# manual dispatch → use the input tag
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cleanup:
runs-on: ubuntu-latest
needs: build-and-push
permissions:
packages: write
steps:
- name: Delete old untagged package versions
run: |
gh api "/user/packages/container/knock-knock/versions?per_page=100" \
--jq '.[] | select(.metadata.container.tags | length == 0) | .id' | \
tail -n +6 | \
xargs -r -I{} gh api --method DELETE \
"/user/packages/container/knock-knock/versions/{}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}