.github/workflows/build-withinfluxreceiver.yaml #9
This file contains hidden or 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
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| required: true | |
| default: '0.142.0' | |
| type: string | |
| description: based on otelcol version | |
| jobs: | |
| otel-custom: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache: false | |
| - name: set artifact id | |
| id: id | |
| run: | | |
| sec=$( date -d "1970-01-01 UTC $(date +%T)" +%s ) | |
| echo "id=$(date +'%Y-%m-%d')-$sec" >> "$GITHUB_OUTPUT" | |
| - name: setup build tool | |
| run: | | |
| set -ex | |
| # get otel build tool | |
| curl --proto =https -fL -o ocb \ | |
| https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/cmd%2Fbuilder%2Fv${{inputs.version}}/ocb_${{inputs.version}}_linux_amd64 | |
| chmod +x ocb | |
| # get manifest of standard otelcol | |
| curl --proto =https -fL -o manifest.yaml \ | |
| https://raw.githubusercontent.com/open-telemetry/opentelemetry-collector-releases/refs/tags/v${{inputs.version}}/distributions/otelcol/manifest.yaml | |
| python -V | |
| export OTELV=${{ inputs.version }} | |
| pip install PyYAML | |
| # Patch manifest.yaml | |
| python -c ' | |
| import yaml | |
| import os | |
| otel_version = os.environ.get("OTELV") | |
| if not otel_version: | |
| raise RuntimeError("Environment variable 'OTELV' is required but not set.") | |
| manifest_path = "manifest.yaml" | |
| with open(manifest_path, "r") as f: | |
| manifest = yaml.safe_load(f) or {} | |
| receivers = manifest.setdefault("receivers", []) | |
| required_receivers = ["influxdbreceiver", "filelogreceiver"] | |
| for name in required_receivers: | |
| exists = any(name in r.get("gomod", "") for r in receivers) | |
| if not exists: | |
| receivers.append({ | |
| "gomod": f"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/{name} v{otel_version}" | |
| }) | |
| with open(manifest_path, "w") as f: | |
| yaml.dump(manifest, f, default_flow_style=False) | |
| ' | |
| cat manifest.yaml | |
| - name: build | |
| run: | | |
| set -ex | |
| ./ocb --config manifest.yaml | |
| - name: Run UPX | |
| uses: crazy-max/ghaction-upx@v3 | |
| with: | |
| version: latest | |
| files: | | |
| _build/otelcol | |
| - uses: actions/upload-artifact@v6 | |
| with: | |
| name: otelcol-${{ inputs.version }}-${{ steps.id.outputs.id }} | |
| path: "_build/otelcol" | |
| if-no-files-found: error |