|
| 1 | +# TODO — if CDK stack added to this repo, migrate auth to GitHub OIDC + dedicated IAM role in |
| 2 | +# 159581800400; delete AWS_ACCESS_KEY_ID/_SECRET secrets. |
| 3 | + |
| 4 | +name: Publish Extend OTel Lambda Layer |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [main] |
| 9 | + paths: |
| 10 | + - 'collector/**' |
| 11 | + - 'nodejs/**' |
| 12 | + - 'extend/**' |
| 13 | + - 'ci-scripts/**' |
| 14 | + - '.github/workflows/publish-extend-otel-layer.yml' |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: read |
| 19 | + |
| 20 | +env: |
| 21 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 22 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-collector: |
| 26 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 27 | + strategy: |
| 28 | + matrix: { architecture: [amd64, arm64] } |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + - uses: actions/setup-go@v5 |
| 32 | + with: |
| 33 | + go-version-file: collector/go.mod |
| 34 | + cache-dependency-path: collector/go.sum |
| 35 | + - run: make -C collector package-extend GOARCH=${{ matrix.architecture }} |
| 36 | + - uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: collector-${{ matrix.architecture }} |
| 39 | + path: collector/build/opentelemetry-collector-layer-${{ matrix.architecture }}.zip |
| 40 | + |
| 41 | + build-nodejs: |
| 42 | + # Only cx-contrib fork needed. cx-js dropped (npm now); import-in-the-middle already from npm. |
| 43 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 44 | + env: |
| 45 | + OPENTELEMETRY_JS_CONTRIB_PATH: ${{ github.workspace }}/opentelemetry-js-contrib |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + with: { repository: coralogix/opentelemetry-js-contrib, ref: coralogix-autoinstrumentation, path: opentelemetry-js-contrib } |
| 50 | + - uses: actions/setup-node@v4 |
| 51 | + with: |
| 52 | + node-version: 22 |
| 53 | + cache: npm |
| 54 | + cache-dependency-path: nodejs/packages/layer/package-lock.json |
| 55 | + - run: ./ci-scripts/build_nodejs_layer.sh |
| 56 | + - env: |
| 57 | + FILE_PATH: ./nodejs/packages/layer/build/layer.zip |
| 58 | + MAX_SIZE: 9437184 |
| 59 | + run: ./ci-scripts/check_size.sh |
| 60 | + - uses: actions/upload-artifact@v4 |
| 61 | + with: |
| 62 | + name: nodejs-layer |
| 63 | + path: nodejs/packages/layer/build/layer.zip |
| 64 | + |
| 65 | + package-and-publish: |
| 66 | + needs: [build-collector, build-nodejs] |
| 67 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 68 | + strategy: |
| 69 | + fail-fast: false |
| 70 | + matrix: |
| 71 | + architecture: [amd64, arm64] |
| 72 | + region: [us-east-1, us-west-2] |
| 73 | + steps: |
| 74 | + - uses: actions/download-artifact@v4 |
| 75 | + with: { name: collector-${{ matrix.architecture }}, path: dl/collector } |
| 76 | + - uses: actions/download-artifact@v4 |
| 77 | + with: { name: nodejs-layer, path: dl/nodejs } |
| 78 | + - name: Merge collector + nodejs zips |
| 79 | + run: | |
| 80 | + set -euo pipefail |
| 81 | + mkdir -p out |
| 82 | + unzip -o dl/collector/opentelemetry-collector-layer-${{ matrix.architecture }}.zip -d out/ |
| 83 | + unzip -o dl/nodejs/layer.zip -d out/ |
| 84 | + (cd out && zip -r ../layer.zip .) |
| 85 | + - name: Publish layer version |
| 86 | + env: |
| 87 | + AWS_REGION: ${{ matrix.region }} |
| 88 | + run: | |
| 89 | + set -euo pipefail |
| 90 | + LAYER_NAME=extend-nodejs-wrapper-and-exporter-${{ matrix.architecture }} |
| 91 | + ARCH=$(echo "${{ matrix.architecture }}" | sed 's/amd64/x86_64/') |
| 92 | + LAYER_ARN=$(aws lambda publish-layer-version \ |
| 93 | + --layer-name "$LAYER_NAME" \ |
| 94 | + --license-info "Apache 2.0" \ |
| 95 | + --compatible-architectures "$ARCH" \ |
| 96 | + --compatible-runtimes nodejs22.x nodejs24.x \ |
| 97 | + --zip-file fileb://layer.zip \ |
| 98 | + --query 'LayerVersionArn' --output text) |
| 99 | + VERSION="${LAYER_ARN##*:}" |
| 100 | + echo "::notice ::$LAYER_ARN" |
| 101 | + aws lambda add-layer-version-permission \ |
| 102 | + --layer-name "$LAYER_NAME" \ |
| 103 | + --version-number "$VERSION" \ |
| 104 | + --statement-id orgVisible \ |
| 105 | + --action lambda:GetLayerVersion \ |
| 106 | + --principal '*' \ |
| 107 | + --organization-id o-7ngcsohuq5 |
0 commit comments