88 branches :
99 - ' *'
1010
11+ concurrency :
12+ group : ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_number || github.event.pull_request.number }}
13+ cancel-in-progress : true
14+
1115permissions :
1216 contents : read
1317 id-token : write
@@ -18,54 +22,151 @@ jobs:
1822 runs-on : ubuntu-latest
1923 steps :
2024 - name : Checkout code
21- uses : actions/checkout@v2
25+ uses : actions/checkout@v3
26+ with :
27+ fetch-depth : 0
2228
2329 - name : Set up nodejs
24- uses : actions/setup-node@v2
30+ uses : actions/setup-node@v3
2531 with :
26- node-version : ' lts/* '
32+ node-version : ' 16.16.0 '
2733 cache : ' npm'
2834
29- - name : npm CI
35+ - name : npm ci
3036 run : npm ci
3137
32- - name : npm Check
38+ - name : npm check
3339 run : npm run check
3440
35- - name : npm Test
36- run : npm run build && npm run test # tests require build to use JS SDK in localhost mode
41+ - name : npm test
42+ run : npm run test -- --coverage
3743
38- - name : npm Build
44+ - name : npm build
3945 run : BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build
4046
41- - name : Configure AWS credentials (development)
42- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
43- uses : aws- actions/configure-aws-credentials@v1
47+ - name : Store assets
48+ if : ${{ github.event_name == 'push' && ( github.ref == 'refs/heads/development' || github.ref == 'refs/heads/master') }}
49+ uses : actions/upload-artifact@v3
4450 with :
45- role-to-assume : arn:aws:iam::079419646996:role/public-assets
51+ name : assets
52+ path : umd/
53+ retention-days : 1
54+
55+ upload-stage :
56+ name : Upload assets
57+ runs-on : ubuntu-latest
58+ needs : build
59+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
60+ strategy :
61+ matrix :
62+ environment :
63+ - stage
64+ - stage-eu
65+ include :
66+ - environment : stage
67+ account_id : " 079419646996"
68+ bucket : split-public-stage
69+ - environment : stage-eu
70+ account_id : " 901851837056"
71+ bucket : split-public-stage-eu-west-1
72+
73+ steps :
74+ - name : Download assets
75+ uses : actions/download-artifact@v3
76+ with :
77+ name : assets
78+ path : umd
79+
80+ - name : Display structure of assets
81+ run : ls -R
82+ working-directory : umd
83+
84+ - name : Configure AWS credentials
85+ uses : aws-actions/configure-aws-credentials@v1-node16
86+ with :
87+ role-to-assume : arn:aws:iam::${{ matrix.account_id }}:role/gha-public-assets-role
4688 aws-region : us-east-1
4789
48- - name : Upload to S3 (development)
49- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/development' }}
90+ - name : Upload to S3
5091 run : aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
5192 env :
52- BUCKET : split-public-stage
93+ BUCKET : ${{ matrix.bucket }}
5394 SOURCE_DIR : ./umd
5495 DEST_DIR : sdk
5596 ARGS : --acl public-read --follow-symlinks --cache-control max-age=31536000,public
5697
57- - name : Configure AWS credentials (master)
58- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
59- uses : aws-actions/configure-aws-credentials@v1
98+ upload-prod :
99+ name : Upload assets
100+ runs-on : ubuntu-latest
101+ needs : build
102+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
103+ strategy :
104+ matrix :
105+ environment :
106+ - prod
107+ - prod-eu
108+ include :
109+ - environment : prod
110+ account_id : " 825951051969"
111+ bucket : split-public
112+ - environment : prod-eu
113+ account_id : " 842946900133"
114+ bucket : split-public-eu-west-1
115+
116+ steps :
117+ - name : Download assets
118+ uses : actions/download-artifact@v3
119+ with :
120+ name : assets
121+ path : umd
122+
123+ - name : Display structure of assets
124+ run : ls -R
125+ working-directory : umd
126+
127+ - name : Configure AWS credentials
128+ uses : aws-actions/configure-aws-credentials@v1-node16
60129 with :
61- role-to-assume : arn:aws:iam::825951051969 :role/public-assets
130+ role-to-assume : arn:aws:iam::${{ matrix.account_id }} :role/gha- public-assets-role
62131 aws-region : us-east-1
63132
64- - name : Upload to S3 (master)
65- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
133+ - name : Upload to S3
66134 run : aws s3 sync $SOURCE_DIR s3://$BUCKET/$DEST_DIR $ARGS
67135 env :
68- BUCKET : split-public
136+ BUCKET : ${{ matrix.bucket }}
69137 SOURCE_DIR : ./umd
70138 DEST_DIR : sdk
71139 ARGS : --acl public-read --follow-symlinks --cache-control max-age=31536000,public
140+
141+ - name : SonarQube Scan (Push)
142+ if : github.event_name == 'push'
143+ uses : SonarSource/sonarcloud-github-action@v1.8
144+ env :
145+ SONAR_TOKEN : ${{ secrets.SONARQUBE_TOKEN }}
146+ with :
147+ projectBaseDir : .
148+ args : >
149+ -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
150+ -Dsonar.projectName=${{ github.event.repository.name }}
151+ -Dsonar.projectKey=${{ github.event.repository.name }}
152+ -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
153+ -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
154+ -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
155+
156+ - name : SonarQube Scan (Pull Request)
157+ if : github.event_name == 'pull_request'
158+ uses : SonarSource/sonarcloud-github-action@v1.8
159+ env :
160+ SONAR_TOKEN : ${{ secrets.SONARQUBE_TOKEN }}
161+ with :
162+ projectBaseDir : .
163+ args : >
164+ -Dsonar.host.url=${{ secrets.SONARQUBE_HOST }}
165+ -Dsonar.projectName=${{ github.event.repository.name }}
166+ -Dsonar.projectKey=${{ github.event.repository.name }}
167+ -Dsonar.links.ci="https://github.com/splitio/${{ github.event.repository.name }}/actions"
168+ -Dsonar.links.scm="https://github.com/splitio/${{ github.event.repository.name }}"
169+ -Dsonar.javascript.lcov.reportPaths=./coverage/lcov.info
170+ -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
171+ -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }}
172+ -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }}
0 commit comments