Skip to content

Commit 3ae0440

Browse files
chore: dedicated builds for promotion workflow (#1779)
1 parent 1f7a449 commit 3ae0440

3 files changed

Lines changed: 254 additions & 35 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Composite action to build and deploy Release Candidate assets to CDN
2+
name: Deploy RC Assets
3+
description: Builds fresh assets from current branch and uploads to environment-specific CDN path
4+
5+
inputs:
6+
environment:
7+
description: 'Environment name for build mode (staging, jp-prod, eu-prod, us-prod)'
8+
required: true
9+
bucket_dir:
10+
description: 'S3 bucket subdirectory (e.g., staging/, jp-prod/)'
11+
required: true
12+
cdn_service:
13+
description: 'Fastly CDN service name (staging-js-agent.newrelic.com or js-agent.newrelic.com)'
14+
required: true
15+
aws_access_key_id:
16+
description: 'AWS access key id'
17+
required: true
18+
aws_secret_access_key:
19+
description: 'AWS secret access key'
20+
required: true
21+
aws_role:
22+
description: 'AWS role ARN'
23+
required: true
24+
aws_bucket_name:
25+
description: 'S3 bucket name'
26+
required: true
27+
fastly_key:
28+
description: 'Fastly access key'
29+
required: true
30+
31+
outputs:
32+
s3_results:
33+
description: 'JSON array of uploaded files'
34+
value: ${{ steps.s3-upload-rc.outputs.results }}
35+
script_url:
36+
description: 'URL of the deployed script'
37+
value: ${{ steps.set-outputs.outputs.script_url }}
38+
version_label:
39+
description: 'Version label for deployment tracking'
40+
value: ${{ steps.set-outputs.outputs.version_label }}
41+
42+
runs:
43+
using: "composite"
44+
steps:
45+
- name: Build RC assets
46+
shell: bash
47+
run: |
48+
echo "🔨 Building fresh assets from current branch for ${{ inputs.environment }} environment"
49+
npm ci
50+
npm run cdn:webpack -- --env mode=${{ inputs.environment }}
51+
echo "📤 Preparing upload to /${{ inputs.bucket_dir }}"
52+
53+
- name: Upload RC assets to S3
54+
id: s3-upload-rc
55+
uses: ./.github/actions/s3-upload
56+
with:
57+
aws_access_key_id: ${{ inputs.aws_access_key_id }}
58+
aws_secret_access_key: ${{ inputs.aws_secret_access_key }}
59+
aws_role: ${{ inputs.aws_role }}
60+
aws_bucket_name: ${{ inputs.aws_bucket_name }}
61+
local_dir: ${{ github.workspace }}/build
62+
bucket_dir: ${{ inputs.bucket_dir }}
63+
64+
- name: Purge CDN cache
65+
uses: ./.github/actions/fastly-purge
66+
with:
67+
fastly_key: ${{ inputs.fastly_key }}
68+
fastly_service: ${{ inputs.cdn_service }}
69+
purge_path: ${{ join(fromJson(steps.s3-upload-rc.outputs.results).*.Key, ' ') }}
70+
71+
- name: Verify CDN assets
72+
uses: ./.github/actions/fastly-verify
73+
with:
74+
fastly_key: ${{ inputs.fastly_key }}
75+
fastly_service: ${{ inputs.cdn_service }}
76+
asset_path: ${{ join(fromJson(steps.s3-upload-rc.outputs.results).*.Key, ' ') }}
77+
78+
- name: Set output values
79+
id: set-outputs
80+
shell: bash
81+
run: |
82+
SCRIPT_URL="https://${{ inputs.cdn_service }}/${{ inputs.bucket_dir }}nr-loader-spa.min.js"
83+
VERSION_LABEL="${{ inputs.environment }}-rc-$(date +%Y%m%d-%H%M%S)"
84+
echo "script_url=$SCRIPT_URL" >> $GITHUB_OUTPUT
85+
echo "version_label=$VERSION_LABEL" >> $GITHUB_OUTPUT
86+
echo "✅ Deployed script: $SCRIPT_URL"
87+
echo "📋 Version label: $VERSION_LABEL"

0 commit comments

Comments
 (0)