-
Notifications
You must be signed in to change notification settings - Fork 35
144 lines (121 loc) · 3.83 KB
/
ci-cd.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: ci-cd
on:
pull_request:
branches:
- master
- development
push:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: read
id-token: write
jobs:
build:
name: Build
# @TODO rollback to ubuntu-latest eventually. ATM, `npm run test-browser` fails when using ubuntu-latest (ubuntu-22.04) with "ERROR [launcher]: Cannot start ChromeHeadless"
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Redis
run: |
sudo add-apt-repository ppa:redislabs/redis
sudo apt-get install -y redis-tools redis-server
- name: Check Redis
run: redis-cli ping
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16.16.0'
cache: 'npm'
- name: npm ci
run: npm ci
- name: npm ts tests
run: npm run test-ts-decls
- name: npm check
run: npm run check
- name: npm test-browser
run: npm run test-browser
- name: npm test-node
run: npm run test-node
- name: npm build
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build
- name: Store assets
if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/rum-agent-integration-suite' || github.ref == 'refs/heads/master') }}
uses: actions/upload-artifact@v3
with:
name: assets
path: umd/
retention-days: 1
upload-stage:
name: Upload assets
runs-on: ubuntu-20.04
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/rum-agent-integration-suite' }}
strategy:
matrix:
environment:
- stage
include:
- environment: stage
account_id: "079419646996"
bucket: split-public-stage
steps:
- name: Download assets
uses: actions/download-artifact@v3
with:
name: assets
path: umd
- name: Display structure of assets
run: ls -R
working-directory: umd
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role
aws-region: us-east-1
- name: Upload to S3
run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
env:
BUCKET: ${{ matrix.bucket }}
SOURCE_DIR: ./umd
DEST_DIR: sdk
ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public
upload-prod:
name: Upload assets
runs-on: ubuntu-20.04
needs: build
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
strategy:
matrix:
environment:
- prod
include:
- environment: prod
account_id: "825951051969"
bucket: split-public
steps:
- name: Download assets
uses: actions/download-artifact@v3
with:
name: assets
path: umd
- name: Display structure of assets
run: ls -R
working-directory: umd
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role
aws-region: us-east-1
- name: Upload to S3
run: aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
env:
BUCKET: ${{ matrix.bucket }}
SOURCE_DIR: ./umd
DEST_DIR: sdk
ARGS: --acl public-read --follow-symlinks --cache-control max-age=31536000,public