Skip to content

Feat/introduction of swohostmetrics receiver - WiP #181

Feat/introduction of swohostmetrics receiver - WiP

Feat/introduction of swohostmetrics receiver - WiP #181

name: Build and Deploy Images
on:
push:
paths-ignore:
- "docs/**"
- "*.md"
tags:
- 'v*.*.*'
branches:
- main
- release/**
pull_request:
branches:
- main
- release/**
workflow_dispatch:
env:
DOCKERHUB_IMAGE: solarwinds/solarwinds-otel-collector
jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check licenses
run: make ci-check-licenses
build_and_test:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.generate-tag.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Docker Image Tag
id: generate-tag
run: echo "tag=v${{ github.run_number }}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build and Test - Full Image
run: >
docker build . --file build/docker/Dockerfile
--tag solarwinds-otel-collector:${{ steps.generate-tag.outputs.tag }}
--tag solarwinds-otel-collector:latest
- name: E2E Tests
working-directory: internal/e2e
run: make e2e-tests
build_k8s:
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.generate-tag.outputs.value }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate Docker Image Tag
id: generate-tag
run: echo "tag=v${{ github.run_number }}-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Build - k8s Image
run: >
docker build . --file build/docker/Dockerfile.k8s
--tag solarwinds-otel-collector:${{ steps.generate-tag.outputs.tag }}-k8s
deploy_dockerhub:
runs-on: ubuntu-latest
needs: build_and_test
name: Deploy to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
environment:
name: production
url: https://hub.docker.com/repository/docker/solarwinds/solarwinds-otel-collector
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Image Tag
id: get-tag
run: echo "tag=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_USER }}
password: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_PASSWORD }}
- name: Build and Push - Full
uses: docker/build-push-action@v6
with:
context: .
file: build/docker/Dockerfile
platforms: linux/amd64,linux/arm64
provenance: false
sbom: false
push: true
tags: |
${{ env.DOCKERHUB_IMAGE }}:${{ steps.get-tag.outputs.tag }}
${{ env.DOCKERHUB_IMAGE }}:latest
create_and_push_docker_manifest:
runs-on: ubuntu-latest
needs:
- deploy_dockerhub
name: Create Multi-platform Docker Manifest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Image Tag
id: get-tag
run: echo "tag=${GITHUB_REF#refs/tags/v*}" >> $GITHUB_OUTPUT
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_USER }}
password: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_PASSWORD }}
- name: Get Manifest for Full Image
run: |
docker manifest inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.get-tag.outputs.tag }} > manifest-full.json
- name: Create Multi-arch Manifest for Full Image
run: |
docker manifest create ${{ env.DOCKERHUB_IMAGE }}:${{ steps.get-tag.outputs.tag }} \
--amend ${{ env.DOCKERHUB_IMAGE }}@$(jq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "amd64") | .digest' manifest-full.json) \
--amend ${{ env.DOCKERHUB_IMAGE }}@$(jq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "arm64") | .digest' manifest-full.json)
- name: Push multi-arch manifest
run: |
docker manifest push ${{ env.DOCKERHUB_IMAGE }}:${{ steps.get-tag.outputs.tag }}
create_release:
runs-on: ubuntu-latest
name: Create GitHub Release
needs:
- create_and_push_docker_manifest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find Previous Tag
run: |
CURRENT_TAG=${GITHUB_REF#refs/tags/}
PREVIOUS_TAG=$(git tag --sort=version:refname | grep -B1 "^${CURRENT_TAG}$" | head -n 1)
echo "Previous tag: $PREVIOUS_TAG"
echo "PREVIOUS_TAG=$PREVIOUS_TAG" >> $GITHUB_ENV
- name: Get Current Tag
id: get-tag
run: echo "tag=${GITHUB_REF#refs/tags/*}" >> $GITHUB_OUTPUT
- name: Create GitHub Release
env:
# for gh cli
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.get-tag.outputs.tag }} \
--title ${{ steps.get-tag.outputs.tag }} \
--latest=false \
--generate-notes \
--notes-start-tag ${{ env.PREVIOUS_TAG }}