Skip to content

Publish Node.js

Publish Node.js #146

name: Publish Node.js
on:
workflow_dispatch:
inputs:
environment:
description: 'Actually publish or just test?'
type: environment
required: true
default: test
jobs:
package:
runs-on: ubuntu-22.04
if: ${{ github.ref == 'refs/heads/coralogix-nodejs-autoinstrumentation' || inputs.environment == 'test' }}
environment: ${{ inputs.environment }}
env:
OPENTELEMETRY_JS_CONTRIB_PATH: ${{ github.workspace }}/opentelemetry-js-contrib
OPENTELEMETRY_JS_PATH: ${{ github.workspace }}/opentelemetry-js
IITM_PATH: ${{ github.workspace }}/import-in-the-middle
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
path: ${{ env.OPENTELEMETRY_JS_CONTRIB_PATH }}
repository: coralogix/opentelemetry-js-contrib
ref: refs/heads/coralogix-autoinstrumentation
ssh-key: ${{ secrets.OPENTELEMETRY_CI_GITHUB_KEY }}
- uses: actions/checkout@v3
with:
path: ${{ env.OPENTELEMETRY_JS_PATH }}
repository: coralogix/opentelemetry-js
ref: refs/heads/coralogix-autoinstrumentation
ssh-key: ${{ secrets.OPENTELEMETRY_CI_GITHUB_KEY }}
- uses: actions/checkout@v3
with:
path: ${{ env.IITM_PATH }}
repository: coralogix/import-in-the-middle
ref: refs/heads/coralogix-autoinstrumentation
ssh-key: ${{ secrets.OPENTELEMETRY_CI_IITM_GITHUB_KEY }}
- name: Build
run: ./ci-scripts/build_nodejs_layer.sh
- name: Check layer size
env:
FILE_PATH: ./nodejs/packages/layer/build/layer.zip
MAX_SIZE: 9437184 # 9MB
run: ./ci-scripts/check_size.sh
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ vars.SIGNER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SIGNER_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.SIGNER_AWS_DEFAULT_REGION }}
- name: Upload package to S3
run: aws s3 cp ./nodejs/packages/layer/build/layer.zip s3://${{ vars.SIGNER_BUCKET }}/to-be-signed/nodejs-layer.zip
- name: Get S3 version of the uploaded file
run: |
LATEST_VERSION=$(aws s3api list-object-versions --bucket ${{ vars.SIGNER_BUCKET }} --prefix to-be-signed/nodejs-layer.zip --query 'Versions[?IsLatest].[VersionId]' --output text)
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
- name: Sign the package
uses: clowdhaus/[email protected]
with:
aws-region: ${{ vars.SIGNER_AWS_DEFAULT_REGION }}
source-s3-bucket: ${{ vars.SIGNER_BUCKET }}
source-s3-key: to-be-signed/nodejs-layer.zip
source-s3-version: ${{ env.LATEST_VERSION }}
destination-s3-bucket: ${{ vars.SIGNER_BUCKET }}
destination-s3-prefix: signed/
profile-name: ${{ vars.SIGNER_PROFILE_NAME }}
max-wait-time: 60
rename-signed-object: true
- name: Download the signed package from S3
run: aws s3 cp s3://${{ vars.SIGNER_BUCKET }}/signed/nodejs-layer.zip ./layer.zip
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: layer.zip
path: ./layer.zip
if-no-files-found: error
retention-days: 1
publish-layer:
runs-on: ubuntu-22.04
if: ${{ github.ref == 'refs/heads/coralogix-nodejs-autoinstrumentation' || inputs.environment == 'test' }}
needs: [package]
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v3
- uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ vars.LAYER_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.LAYER_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.LAYER_AWS_DEFAULT_REGION }}
- name: create target dir
run: mkdir -p target
- name: Download layer.zip
uses: actions/download-artifact@v3
with:
name: layer.zip
path: target
- name: Publish layer
env:
LAYER_NAME: "coralogix-opentelemetry-nodejs-wrapper"
COMPATIBLE_RUNTIMES: "nodejs16.x nodejs18.x nodejs20.x"
run: ./ci-scripts/publish_${{ inputs.environment }}.sh