-
Notifications
You must be signed in to change notification settings - Fork 87
83 lines (68 loc) · 4.01 KB
/
deploy-dev.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploy to Development Environment
on:
workflow_dispatch:
pull_request:
branches: ['develop']
types:
- closed
permissions:
id-token: write # allows the JWT to be requested from GitHub's OIDC provider
contents: read # This is required for actions/checkout
env:
NODE_OPTIONS: "--no-warnings"
jobs:
deploy-tag:
name: Deploy to development environment
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/hotfix/') || startsWith(github.ref, 'refs/heads/develop/') || github.event.pull_request.merged == true
steps:
- name: Install AWS cli
uses: unfor19/install-aws-cli-action@master
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_DEV_ACCOUNT_ID }}:role/${{ secrets.AWS_DEV_S3_SYNC_ROLE }}
aws-region: us-east-1
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install dependencies
env:
HUSKY: 0
REMOTE_MODULES_BASE_PATH: 'https://cdn.rudderlabs.com/dev/latest/v3/modern/plugins'
BUGSNAG_API_KEY: ${{ secrets.RS_DEV_BUGSNAG_API_KEY }}
BUGSNAG_RELEASE_STAGE: 'development'
run: |
npm run setup:ci
- name: Build files
env:
REMOTE_MODULES_BASE_PATH: 'https://cdn.rudderlabs.com/dev/latest/v3/modern/plugins'
BUGSNAG_API_KEY: ${{ secrets.RS_DEV_BUGSNAG_API_KEY }}
BUGSNAG_RELEASE_STAGE: 'development'
run: |
npm run build:browser
npm run build:browser:modern
- name: Sync files to S3
run: |
aws s3 cp packages/analytics-js/dist/cdn/legacy/iife/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/legacy/ --recursive --cache-control max-age=3600
aws s3 cp packages/analytics-js/dist/cdn/modern/iife/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/modern/ --recursive --cache-control max-age=3600
aws s3 cp packages/analytics-js-plugins/dist/cdn/legacy/plugins/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/legacy/plugins/ --recursive --cache-control max-age=3600
aws s3 cp packages/analytics-js-plugins/dist/cdn/modern/plugins/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/modern/plugins/ --recursive --cache-control max-age=3600
aws s3 cp packages/analytics-js-integrations/dist/cdn/legacy/js-integrations/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/legacy/js-integrations/ --recursive --cache-control max-age=3600
aws s3 cp packages/analytics-js-integrations/dist/cdn/modern/js-integrations/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/v3/modern/js-integrations/ --recursive --cache-control max-age=3600
- name: Create Cloudfront invalidation
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DEV_CF_DISTRIBUTION_ID }} --paths "/dev/latest/v3*"
# Below steps are for v1.1 SDK (legacy)
- name: Sync files to S3 (v1.1)
run: |
aws s3 cp packages/analytics-v1.1/dist/cdn/legacy/rudder-analytics.min.js s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/rudder-analytics.min.js --cache-control max-age=3600
aws s3 cp packages/analytics-v1.1/dist/cdn/legacy/rudder-analytics.min.js.map s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/rudder-analytics.min.js.map --cache-control max-age=3600
aws s3 cp packages/analytics-js-integrations/dist/cdn/legacy/js-integrations/ s3://${{ secrets.AWS_DEV_S3_BUCKET_NAME }}/dev/latest/js-integrations/ --recursive --cache-control max-age=3600
- name: Create Cloudfront invalidation
run: |
AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DEV_CF_DISTRIBUTION_ID }} --paths "/dev/latest*"