Read pod status from manifests #2334
Workflow file for this run
This file contains 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 Deploy Images | |
on: | |
push: | |
paths-ignore: | |
- "docs/**" | |
- "*.md" | |
- "deploy/helm/*.md" | |
tags: | |
- '*.*.*' | |
pull_request: | |
branches: | |
- master | |
- release/** | |
workflow_dispatch: | |
env: | |
DOCKERHUB_IMAGE: solarwinds/swi-opentelemetry-collector | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
outputs: | |
image_tag: ${{ steps.generate-tag.outputs.value }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Deploy skaffold | |
uses: ./.github/actions/deploy-skaffold | |
- name: Create k8s Kind Cluster | |
uses: helm/[email protected] | |
with: | |
version: v0.24.0 | |
kubectl_version: v1.31.0 | |
node_image: kindest/node:v1.31.0 | |
cluster_name: kind | |
- name: Add dependency chart repos | |
run: | | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts | |
helm repo add jetstack https://charts.jetstack.io | |
- name: Generate docker image tag | |
id: generate-tag | |
run: echo "::set-output name=value::v${{ github.run_number }}-$(git rev-parse --short HEAD)" | |
- name: Build | |
run: skaffold build --file-output=/tmp/tags.json --tag ${{ steps.generate-tag.outputs.value }} | |
- name: Test | |
run: skaffold test --build-artifacts=/tmp/tags.json | |
- name: Copy image to Kind cluster | |
run: | | |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="integration-test") | .tag' /tmp/tags.json) | |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="swi-k8s-opentelemetry-collector") | .tag' /tmp/tags.json) | |
kind load docker-image $(jq -r '.builds[] | select(.imageName=="swi-k8s-opentelemetry-collector-tests") | .tag' /tmp/tags.json) | |
- name: Setup kubetail | |
run: | | |
curl -Lo kubetail https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail && sudo install kubetail /usr/local/bin/ | |
shell: bash | |
- name: Deploy services using Skaffold | |
run: skaffold deploy --build-artifacts=/tmp/tags.json --kube-context kind-kind | |
- name: Show all resources | |
if: ${{ failure() }} | |
run: | | |
kubectl get all -n test-namespace | |
- name: Run integration tests | |
uses: ./.github/actions/run-integration-tests | |
build_and_test_windows: | |
runs-on: windows-2022 | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector') | |
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 "::set-output name=value::v${{ github.run_number }}-$(git rev-parse --short HEAD)" | |
- name: Build | |
run: | | |
docker build -t swi-k8s-opentelemetry-collector:${{ steps.generate-tag.outputs.value }}-nanoserver-ltsc2022 -f build/docker/Dockerfile.Windows-2022 . | |
- name: CP assets | |
run: | | |
docker create --name assets swi-k8s-opentelemetry-collector:${{ steps.generate-tag.outputs.value }}-nanoserver-ltsc2022 | |
docker cp assets:/swi-otelcol.exe swi-otelcol.exe | |
docker cp assets:/wrapper.exe wrapper.exe | |
- name: Build 2019 | |
run: | | |
docker build -t swi-k8s-opentelemetry-collector:${{ steps.generate-tag.outputs.value }}-nanoserver-ltsc2019 --build-arg WINBASE=mcr.microsoft.com/windows/nanoserver:ltsc2019 -f build/docker/Dockerfile.Windows-Runtime . | |
- name: Save image | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector') | |
run: | | |
docker save --output swi-k8s-opentelemetry-collector-windows-ltsc2022.tar swi-k8s-opentelemetry-collector:${{ steps.generate-tag.outputs.value }}-nanoserver-ltsc2022 | |
docker save --output swi-k8s-opentelemetry-collector-windows-ltsc2019.tar swi-k8s-opentelemetry-collector:${{ steps.generate-tag.outputs.value }}-nanoserver-ltsc2019 | |
- uses: actions/upload-artifact@v3 | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector') | |
with: | |
name: image | |
path: | | |
swi-k8s-opentelemetry-collector-windows-ltsc2022.tar | |
swi-k8s-opentelemetry-collector-windows-ltsc2019.tar | |
retention-days: 2 | |
deploy_dockerhub: | |
runs-on: ubuntu-latest | |
needs: build_and_test | |
name: Deploy to docker hub | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector') | |
environment: | |
name: production | |
url: https://hub.docker.com/repository/docker/solarwinds/swi-opentelemetry-collector | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get image tag | |
id: vars | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | |
- 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 | |
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.vars.outputs.tag }} | |
deploy_dockerhub_windows: | |
runs-on: windows-2022 | |
needs: build_and_test_windows | |
name: Deploy to docker hub Windows | |
if: startsWith(github.ref, 'refs/tags/') && !contains(github.ref, 'swo-k8s-collector') | |
environment: | |
name: production | |
url: https://hub.docker.com/repository/docker/solarwinds/swi-opentelemetry-collector | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: image | |
- name: Get image tag | |
id: vars | |
run: echo "tag=$env:GITHUB_REF_NAME" >> $ENV:GITHUB_OUTPUT | |
- name: Load image | |
run: | | |
docker load --input swi-k8s-opentelemetry-collector-windows-ltsc2022.tar | |
docker load --input swi-k8s-opentelemetry-collector-windows-ltsc2019.tar | |
- name: Tag images | |
run: | | |
docker tag swi-k8s-opentelemetry-collector:${{ needs.build_and_test_windows.outputs.image_tag }}-nanoserver-ltsc2022 ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022 | |
docker tag swi-k8s-opentelemetry-collector:${{ needs.build_and_test_windows.outputs.image_tag }}-nanoserver-ltsc2019 ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2019 | |
- name: Docker login | |
env: | |
OPENTELEMETRY_DOCKER_HUB_CI_PASSWORD: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_PASSWORD }} | |
OPENTELEMETRY_DOCKER_HUB_CI_USER: ${{ secrets.OPENTELEMETRY_DOCKER_HUB_CI_USER }} | |
run: echo "$env:OPENTELEMETRY_DOCKER_HUB_CI_PASSWORD" | docker login -u "$env:OPENTELEMETRY_DOCKER_HUB_CI_USER" --password-stdin | |
- name: Push as specific | |
run: | | |
docker push ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022 | |
docker push ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2019 | |
create_and_push_manifest: | |
runs-on: ubuntu-latest | |
name: Create Multi-platform Docker Manifest | |
needs: | |
- deploy_dockerhub_windows | |
- deploy_dockerhub | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get image tag | |
id: vars | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | |
- 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 linux manifest | |
run: | | |
docker manifest inspect ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }} > manifest.json | |
- name: Create multi-arch manifest | |
run: | | |
docker manifest create ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }} \ | |
--amend ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2022 \ | |
--amend ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }}-nanoserver-ltsc2019 \ | |
--amend ${{ env.DOCKERHUB_IMAGE }}@$(jq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "amd64") | .digest' manifest.json) \ | |
--amend ${{ env.DOCKERHUB_IMAGE }}@$(jq -r '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "arm64") | .digest' manifest.json) | |
- name: Push multi-arch manifest | |
run: | | |
docker manifest push ${{ env.DOCKERHUB_IMAGE }}:${{ steps.vars.outputs.tag }} | |
create_release: | |
runs-on: ubuntu-latest | |
name: Create GitHub Release | |
needs: | |
- create_and_push_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: vars | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} | |
- name: Create Github Release | |
env: | |
# for gh cli | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release create ${{ steps.vars.outputs.tag }} \ | |
--title ${{ steps.vars.outputs.tag }} \ | |
--latest=false \ | |
--generate-notes \ | |
--notes-start-tag ${{ env.PREVIOUS_TAG }} |