Skip to content

Fix validation workflow #18

Fix validation workflow

Fix validation workflow #18

name: Docker Image
on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- .github/workflows/build-and-publish.yml
- Dockerfile
- protoc-wrapper
release:
types: [published]
# allow running release workflow manually
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
install: true
- name: Start local Docker registry
if: ${{ github.event_name == 'pull_request' }}
shell: /bin/bash
run: |
docker inspect registry > /dev/null || docker run --rm -d -p 5000:5000 --name registry registry:2
check_ready() {
url="http://localhost:5000/v2/"
end_time=$((SECONDS + 60))
while [[ $SECONDS -lt $end_time ]]; do
response=$(curl -s -I -o /dev/null -w "%{http_code}" $url)
if [[ $response -ge 200 && $response -lt 300 ]]; then
echo "Registry endpoint available at $url"
return 0
fi
echo "Registry endpoint not available yet"
sleep 10
done
echo "Registry endpoint unavailable"
return 1
}
check_ready
- name: Extract tags/labels from Git
id: docker_meta
uses: docker/metadata-action@v5
with:
# when running on pull request we want to push the image to local registry for further testing
images: |
jaegertracing/protobuf,enable=${{ github.event_name != 'pull_request' }}
localhost:5000/jaegertracing/protobuf,enable=${{ github.event_name == 'pull_request' }}
# The 'tags:' section defines how the Docker image will be tagged:
# - pushes to main branch will be published as 'latest'
# - pushes tagged with semver will be published as that version (without 'v')
# - other tags can be used as is
# Documentation: https://github.com/docker/metadata-action#tags-input
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=semver,pattern={{version}}
type=ref,event=tag
type=sha,enable=${{ github.event_name == 'pull_request' }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and maybe push Docker image
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: test that image can be run
run: docker run --platform linux/amd64 ${{ steps.docker_meta.outputs.tags }}
# The following steps run only on pull requests and validate
# that the new image can run successfully in Jaeger repos.
# We do not check if the generated files would be different there,
# only that the build does not fail.
- name: Checkout Jaeger for validation
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: jaegertracing/jaeger
submodules: recursive
path: jaeger
- name: Build Proto in Jaeger
if: github.event_name == 'pull_request'
working-directory: jaeger
run: make proto DOCKER_PROTOBUF=${{ steps.docker_meta.outputs.tags }}
- name: Checkout jaeger-idl for validation
if: github.event_name == 'pull_request'
uses: actions/checkout@v4
with:
repository: jaegertracing/jaeger-idl
submodules: recursive
path: jaeger-idl
- name: Build Proto in jaeger-idl
if: github.event_name == 'pull_request'
working-directory: jaeger-idl
run: make proto PROTOC_IMAGE=${{ steps.docker_meta.outputs.tags }}