@fat-zebra/sdk 1.5.10-beta.1 → 1.5.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.github/workflows/ci.yml
CHANGED
|
@@ -2,15 +2,13 @@ name: CI
|
|
|
2
2
|
|
|
3
3
|
env:
|
|
4
4
|
AWS_REGION: ap-southeast-2
|
|
5
|
-
TEST_UPLOAD_PATH: s3://test-cdn-pmnts-origin/sdk/v1/
|
|
6
5
|
SBOX_UPLOAD_PATH: s3://sandbox-pmnts-resources/sdk/v1/
|
|
7
6
|
PROD_UPLOAD_PATH: s3://pmnts-resources/sdk/v1/
|
|
8
|
-
TEST_CLOUDFRONT_ID: "E1MCI9BNDVLHEU"
|
|
9
7
|
SBOX_CLOUDFRONT_ID: "E5G12OAJDKLBT"
|
|
10
8
|
PROD_CLOUDFRONT_ID: "E3348QX8Q2J4OV"
|
|
11
9
|
on:
|
|
12
10
|
push:
|
|
13
|
-
branches: ['
|
|
11
|
+
branches: ['main']
|
|
14
12
|
tags:
|
|
15
13
|
- 'v*.*.*' # prod tags e.g. v1.5.8
|
|
16
14
|
- 'v*.*.*-beta.*' # beta tags e.g. v1.5.8-beta.0
|
|
@@ -33,34 +31,9 @@ jobs:
|
|
|
33
31
|
|
|
34
32
|
# --- BUILD JOBS ----------------------------------------------------
|
|
35
33
|
|
|
36
|
-
build-staging:
|
|
37
|
-
needs: checks
|
|
38
|
-
if: github.ref_type == 'branch' && github.ref_name != 'main'
|
|
39
|
-
runs-on: ubuntu-latest
|
|
40
|
-
env:
|
|
41
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
42
|
-
steps:
|
|
43
|
-
- uses: actions/checkout@v4
|
|
44
|
-
- uses: fatzebra/gh-workflows/build_npm@main
|
|
45
|
-
with:
|
|
46
|
-
credentials_json: |
|
|
47
|
-
{
|
|
48
|
-
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
|
|
49
|
-
"NPM_CLOUDSMITH_REPO_PWD": "${{ secrets.CLOUDSMITH_API_KEY }}"
|
|
50
|
-
}
|
|
51
|
-
- name: Build (staging)
|
|
52
|
-
run: npm run build:staging
|
|
53
|
-
- uses: actions/upload-artifact@v4
|
|
54
|
-
with:
|
|
55
|
-
name: sdk-dist-staging
|
|
56
|
-
path: |
|
|
57
|
-
dist/staging/*.js
|
|
58
|
-
dist/staging/*.css
|
|
59
|
-
if-no-files-found: error
|
|
60
|
-
|
|
61
34
|
build-sandbox:
|
|
62
35
|
needs: checks
|
|
63
|
-
if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
|
|
36
|
+
if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
|
|
64
37
|
runs-on: ubuntu-latest
|
|
65
38
|
env:
|
|
66
39
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -85,7 +58,7 @@ jobs:
|
|
|
85
58
|
|
|
86
59
|
build-production:
|
|
87
60
|
needs: checks
|
|
88
|
-
if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
|
|
61
|
+
if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
|
|
89
62
|
runs-on: ubuntu-latest
|
|
90
63
|
env:
|
|
91
64
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -109,45 +82,8 @@ jobs:
|
|
|
109
82
|
if-no-files-found: error
|
|
110
83
|
|
|
111
84
|
# --- DEPLOY JOBS ----------------------------------------------------
|
|
112
|
-
|
|
113
|
-
deploy-staging:
|
|
114
|
-
if: github.ref_type == 'branch' && github.ref_name != 'main'
|
|
115
|
-
needs:
|
|
116
|
-
- build-staging
|
|
117
|
-
runs-on: ubuntu-latest
|
|
118
|
-
permissions:
|
|
119
|
-
id-token: write
|
|
120
|
-
contents: read
|
|
121
|
-
steps:
|
|
122
|
-
- uses: actions/download-artifact@v4
|
|
123
|
-
with:
|
|
124
|
-
name: sdk-dist-staging
|
|
125
|
-
path: dist/staging/
|
|
126
|
-
- uses: fatzebra/gh-workflows/aws_login@main
|
|
127
|
-
with:
|
|
128
|
-
platform: fz
|
|
129
|
-
environment: test
|
|
130
|
-
role_name: AppDeploy
|
|
131
|
-
|
|
132
|
-
- run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/staging/ "${TEST_UPLOAD_PATH}"
|
|
133
|
-
- run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/staging/ "${TEST_UPLOAD_PATH}"
|
|
134
|
-
|
|
135
|
-
- name: Invalidate CloudFront cache
|
|
136
|
-
shell: bash
|
|
137
|
-
run: |
|
|
138
|
-
invalidation_id=$(aws cloudfront create-invalidation \
|
|
139
|
-
--distribution-id "${TEST_CLOUDFRONT_ID}" \
|
|
140
|
-
--paths '/sdk/*' \
|
|
141
|
-
--output text \
|
|
142
|
-
--query 'Invalidation.Id')
|
|
143
|
-
echo "Invalidation started: ${invalidation_id}"
|
|
144
|
-
aws cloudfront wait invalidation-completed \
|
|
145
|
-
--distribution-id "${TEST_CLOUDFRONT_ID}" \
|
|
146
|
-
--id "${invalidation_id}"
|
|
147
|
-
echo "Invalidation completed."
|
|
148
|
-
|
|
149
85
|
deploy-sandbox:
|
|
150
|
-
if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
|
|
86
|
+
if: github.ref_type == 'tag' && contains(github.ref_name, '-beta.')
|
|
151
87
|
needs:
|
|
152
88
|
- build-sandbox
|
|
153
89
|
runs-on: ubuntu-latest
|
|
@@ -182,7 +118,7 @@ jobs:
|
|
|
182
118
|
echo "Invalidation completed."
|
|
183
119
|
|
|
184
120
|
deploy-production:
|
|
185
|
-
if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
|
|
121
|
+
if: github.ref_type == 'tag' && !contains(github.ref_name, '-beta.')
|
|
186
122
|
needs:
|
|
187
123
|
- build-production
|
|
188
124
|
runs-on: ubuntu-latest
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
name: Non Prod CI
|
|
2
|
+
|
|
3
|
+
env:
|
|
4
|
+
AWS_REGION: ap-southeast-2
|
|
5
|
+
TEST_UPLOAD_PATH: s3://test-cdn-pmnts-origin/sdk/v1/
|
|
6
|
+
TEST_CLOUDFRONT_ID: "E1MCI9BNDVLHEU"
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches-ignore:
|
|
10
|
+
- main
|
|
11
|
+
tags:
|
|
12
|
+
- 'v*.*.*-beta.*'
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
checks:
|
|
16
|
+
name: Security & Type checks
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
env:
|
|
19
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with: { node-version: '20.x', cache: 'npm' }
|
|
24
|
+
- run: npm ci
|
|
25
|
+
- run: npx --yes audit-ci --high
|
|
26
|
+
- run: npx tsc --noEmit
|
|
27
|
+
- run: npx tsc -p tsconfig.package.json --noEmit
|
|
28
|
+
- run: yarn test
|
|
29
|
+
|
|
30
|
+
# --- BUILD JOBS ----------------------------------------------------
|
|
31
|
+
|
|
32
|
+
build-staging:
|
|
33
|
+
needs: checks
|
|
34
|
+
if: github.ref_type == 'branch' && github.ref_name != 'main'
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
env:
|
|
37
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: fatzebra/gh-workflows/build_npm@main
|
|
41
|
+
with:
|
|
42
|
+
credentials_json: |
|
|
43
|
+
{
|
|
44
|
+
"GITHUB_TOKEN": "${{ secrets.GITHUB_TOKEN }}",
|
|
45
|
+
"NPM_CLOUDSMITH_REPO_PWD": "${{ secrets.CLOUDSMITH_API_KEY }}"
|
|
46
|
+
}
|
|
47
|
+
- name: Build (staging)
|
|
48
|
+
run: npm run build:staging
|
|
49
|
+
- uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: sdk-dist-staging
|
|
52
|
+
path: |
|
|
53
|
+
dist/staging/*.js
|
|
54
|
+
dist/staging/*.css
|
|
55
|
+
if-no-files-found: error
|
|
56
|
+
|
|
57
|
+
# --- DEPLOY JOBS ----------------------------------------------------
|
|
58
|
+
|
|
59
|
+
deploy-staging:
|
|
60
|
+
if: github.ref_type == 'branch' && github.ref_name != 'main'
|
|
61
|
+
needs:
|
|
62
|
+
- build-staging
|
|
63
|
+
runs-on: ubuntu-latest
|
|
64
|
+
permissions:
|
|
65
|
+
id-token: write
|
|
66
|
+
contents: read
|
|
67
|
+
steps:
|
|
68
|
+
- uses: actions/download-artifact@v4
|
|
69
|
+
with:
|
|
70
|
+
name: sdk-dist-staging
|
|
71
|
+
path: dist/staging/
|
|
72
|
+
- uses: fatzebra/gh-workflows/aws_login@main
|
|
73
|
+
with:
|
|
74
|
+
platform: fz
|
|
75
|
+
environment: test
|
|
76
|
+
role_name: AppDeploy
|
|
77
|
+
|
|
78
|
+
- run: aws s3 sync --delete --content-type 'application/javascript' --exclude '*' --include '*.js' dist/staging/ "${TEST_UPLOAD_PATH}"
|
|
79
|
+
- run: aws s3 sync --delete --content-type 'text/css' --exclude '*' --include '*.css' dist/staging/ "${TEST_UPLOAD_PATH}"
|
|
80
|
+
|
|
81
|
+
- name: Invalidate CloudFront cache
|
|
82
|
+
shell: bash
|
|
83
|
+
run: |
|
|
84
|
+
invalidation_id=$(aws cloudfront create-invalidation \
|
|
85
|
+
--distribution-id "${TEST_CLOUDFRONT_ID}" \
|
|
86
|
+
--paths '/sdk/*' \
|
|
87
|
+
--output text \
|
|
88
|
+
--query 'Invalidation.Id')
|
|
89
|
+
echo "Invalidation started: ${invalidation_id}"
|
|
90
|
+
aws cloudfront wait invalidation-completed \
|
|
91
|
+
--distribution-id "${TEST_CLOUDFRONT_ID}" \
|
|
92
|
+
--id "${invalidation_id}"
|
|
93
|
+
echo "Invalidation completed."
|
|
94
|
+
|
|
95
|
+
# Publish to npm for beta tags and production tags
|
|
96
|
+
publish-npm-beta:
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
if: startsWith(github.ref, 'refs/tags/') && contains(github.ref_name, '-beta.')
|
|
99
|
+
env:
|
|
100
|
+
TAG_NAME: ${{ github.ref_name }} # e.g. v1.5.10-beta.0
|
|
101
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
102
|
+
steps:
|
|
103
|
+
- uses: actions/checkout@v4
|
|
104
|
+
with:
|
|
105
|
+
fetch-depth: 0
|
|
106
|
+
|
|
107
|
+
- uses: actions/setup-node@v4
|
|
108
|
+
with:
|
|
109
|
+
node-version: 20
|
|
110
|
+
registry-url: 'https://registry.npmjs.org' # writes .npmrc using NPM_TOKEN
|
|
111
|
+
|
|
112
|
+
- name: Show tag name
|
|
113
|
+
run: echo "Publishing for tag $TAG_NAME"
|
|
114
|
+
|
|
115
|
+
# make package.json version match the git tag (strip leading "v" if present)
|
|
116
|
+
- name: Sync package.json version to git tag
|
|
117
|
+
run: |
|
|
118
|
+
VERSION="${TAG_NAME#v}"
|
|
119
|
+
npm version --no-git-tag-version "$VERSION"
|
|
120
|
+
|
|
121
|
+
- name: Install deps
|
|
122
|
+
run: npm ci
|
|
123
|
+
|
|
124
|
+
- name: Run package build
|
|
125
|
+
run: npm run build:package
|
|
126
|
+
|
|
127
|
+
- name: Publish (beta dist-tag)
|
|
128
|
+
run: npm publish --access public --tag beta
|