Skip to content

Commit f4bfb2f

Browse files
Version 1.0.0
Merge pull request #23 from KeyValueSoftwareSystems/dev
2 parents 5fb96ba + 23c3582 commit f4bfb2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+12883
-1
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
API_DOMAIN = https://api.sirenapp.io/

.eslintrc.cjs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true
5+
},
6+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
7+
overrides: [
8+
{
9+
env: {
10+
node: true
11+
},
12+
files: ['.eslintrc.{js,cjs}'],
13+
parserOptions: {
14+
sourceType: 'script'
15+
}
16+
}
17+
],
18+
parser: '@typescript-eslint/parser',
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
sourceType: 'module'
22+
},
23+
plugins: ['@typescript-eslint'],
24+
rules: {
25+
'no-plusplus': 'off',
26+
'comma-dangle': ['off'],
27+
'import/no-extraneous-dependencies': 'off',
28+
'import/extensions': 'off',
29+
'import/no-unresolved': 'off',
30+
'@typescript-eslint/no-unused-vars': [
31+
'error',
32+
{
33+
ignoreRestSiblings: true,
34+
vars: 'local'
35+
}
36+
],
37+
'no-shadow': 'off',
38+
'implicit-arrow-linebreak': 'off',
39+
'space-before-blocks': 'error',
40+
'function-paren-newline': 'off',
41+
'padding-line-between-statements': [
42+
'error',
43+
{
44+
blankLine: 'always',
45+
prev: '*',
46+
next: 'return'
47+
},
48+
{
49+
blankLine: 'always',
50+
prev: ['const', 'let', 'var'],
51+
next: '*'
52+
},
53+
{
54+
blankLine: 'any',
55+
prev: ['const', 'let', 'var'],
56+
next: ['const', 'let', 'var']
57+
}
58+
],
59+
'object-curly-newline': 'off',
60+
'func-call-spacing': 'off',
61+
'operator-linebreak': 'off',
62+
'import/prefer-default-export': 'off',
63+
'no-spaced-func': 'off',
64+
'@typescript-eslint/consistent-type-imports': 'error',
65+
indent: ["error", 2, { "SwitchCase": 1}],
66+
curly: ['error', 'multi', 'consistent'],
67+
'no-confusing-arrow': 'off',
68+
'nonblock-statement-body-position': 'off',
69+
'@typescript-eslint/no-explicit-any': 'off'
70+
}
71+
};

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
This template outlines the recommended format for creating pull requests within this project. Please fill out all sections before submitting your PR
2+
3+
## Branch Naming:
4+
5+
- Use a descriptive branch name that reflects the change and follows the format: [type]/[brief-description]
6+
- Replace [type] with feature, fix, refactor, hotfix, or other relevant categories
7+
- Keep the description concise and clear
8+
9+
## Commit Guidelines:
10+
11+
- Adhere to the "scope:subject" commit message structure
12+
- Scope can be feat, fix, docs, test, refactor, build, format, etc.
13+
- Use imperative tense (e.g., "fix: User unable to login")
14+
## Pull Request Checklist:
15+
16+
[ ] **Read the contributing guidelines** <br />
17+
[ ] **Branch is up-to-date with the base branch: main (or other designated branch)**<br />
18+
[ ] **Changes pass all tests: npm test or yarn test (or equivalent command)**<br />
19+
[ ] **Documentation has been updated (if applicable)**<br />
20+
## Description:
21+
- Start your pull request summary with a clear and informative heading. Use the Markdown syntax `##` for the heading, like `## Your Heading Here`.
22+
- For the section detailing the changes introduced by this pull request, use the Markdown heading `## Changes`.
23+
- Briefly describe the changes introduced in this pull request.Ensure that the changelog has been updated accordingly
24+
- Explain the motivation and the problem it solves
25+
- Mention any breaking changes
26+
- Link to related issues or internal tickets
27+
## Additional Notes:
28+
29+
- Include any other relevant information, such as limitations, known issues, or future improvements.
30+
## Screenshots (if applicable):
31+
32+
- Add screenshots or GIFs to help visualize your changes.
33+
## Testing Instructions:
34+
35+
- Provide step-by-step instructions on how to test your changes
36+
## Checklist for Reviewers:
37+
38+
[ ] **Code follows project conventions and style guidelines**<br />
39+
[ ] **Changes do not introduce new warnings or errors**<br />
40+
[ ] **Unit tests cover the changes adequately**<br />
41+
[ ] **Documentation is updated correctly and reflects the changes**<br />
42+
Additional Information:
43+
44+
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT License.
45+
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: Hosting for js-sdk
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
Environment:
7+
required: true
8+
type: choice
9+
description: Choose env
10+
options:
11+
- dev
12+
- stg
13+
- prd
14+
push:
15+
paths-ignore:
16+
- "**.md"
17+
branches:
18+
- dev
19+
- stg
20+
21+
env:
22+
SERVICE_NAME: siren-js
23+
AWS_REGION: "ap-south-1"
24+
25+
jobs:
26+
prepare-env:
27+
name: Prepare Env
28+
runs-on: "ubuntu-latest"
29+
timeout-minutes: 2
30+
outputs:
31+
AWS_ROLE: ${{ steps.vars.outputs.AWS_ROLE }}
32+
ENV: ${{ steps.vars.outputs.ENV }}
33+
PROJECT_PREFIX: ${{ steps.vars.outputs.PROJECT_PREFIX }}
34+
DISTRIBUTION_ID: ${{ steps.vars.outputs.DISTRIBUTION_ID }}
35+
ENVIRONMENT_BUCKET: ${{ steps.set_env.outputs.ENVIRONMENT_BUCKET }}
36+
STATIC_HOSTING_BUCKET: ${{ steps.set_env.outputs.STATIC_HOSTING_BUCKET }}
37+
SLACK_WEBHOOK_URL: ${{ steps.vars.outputs.SLACK_WEBHOOK_URL }}
38+
39+
steps:
40+
- id: vars
41+
run: |
42+
BRANCH="${GITHUB_REF#refs/heads/}"
43+
ENV=${{ github.event.inputs.environment }}
44+
echo $BRANCH
45+
46+
if [ -z "$ENV" ]
47+
then
48+
case $BRANCH in
49+
"dev")
50+
ENV="dev"
51+
;;
52+
"stg")
53+
ENV="stg"
54+
;;
55+
"main")
56+
ENV="prd"
57+
;;
58+
*)
59+
echo "ENV not configured" && exit 1
60+
;;
61+
esac
62+
fi
63+
if [[ $ENV == 'prd' && $BRANCH == 'main' ]]
64+
then
65+
echo "AWS_ROLE=PRD_AWS_ROLE" >> $GITHUB_OUTPUT
66+
echo "DISTRIBUTION_ID=PRD_DISTRIBUTION_ID" >> $GITHUB_OUTPUT
67+
echo "PROJECT_PREFIX=sirn-prd-mb" >> $GITHUB_OUTPUT
68+
echo "SLACK_WEBHOOK_URL=PRD_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT
69+
elif [ $ENV == 'stg' ]
70+
then
71+
echo "AWS_ROLE=STG_AWS_ROLE" >> $GITHUB_OUTPUT
72+
echo "DISTRIBUTION_ID=STG_DISTRIBUTION_ID" >> $GITHUB_OUTPUT
73+
echo "PROJECT_PREFIX=sirn-stg-mb" >> $GITHUB_OUTPUT
74+
echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT
75+
elif [ $ENV == 'dev' ]
76+
then
77+
echo "AWS_ROLE=DEV_AWS_ROLE" >> $GITHUB_OUTPUT
78+
echo "DISTRIBUTION_ID=DEV_DISTRIBUTION_ID" >> $GITHUB_OUTPUT
79+
echo "PROJECT_PREFIX=sirn-dev-mb" >> $GITHUB_OUTPUT
80+
echo "SLACK_WEBHOOK_URL=DEV_SLACK_WEBHOOK_URL" >> $GITHUB_OUTPUT
81+
else
82+
echo "Branch not configured!"
83+
exit 1
84+
fi
85+
echo "ENV=$ENV" >> $GITHUB_OUTPUT
86+
echo ":rocket: Environment - $ENV " >> $GITHUB_STEP_SUMMARY
87+
- name: set variables
88+
id: set_env
89+
run: |
90+
PROJECT_PREFIX=${{ steps.vars.outputs.PROJECT_PREFIX }}
91+
echo "PROJECT_PREFIX=$PROJECT_PREFIX" >> $GITHUB_OUTPUT
92+
echo "ENVIRONMENT_BUCKET=$PROJECT_PREFIX-s3-environment" >> $GITHUB_OUTPUT
93+
echo "AWS_REGION=ap-southeast-1" >> $GITHUB_OUTPUT
94+
echo "STATIC_HOSTING_BUCKET=$PROJECT_PREFIX-$SERVICE_NAME-website" >> $GITHUB_OUTPUT
95+
echo ":seedling: Branch:${GITHUB_REF#refs/heads/}" >> $GITHUB_STEP_SUMMARY
96+
97+
static-host:
98+
name: Static Hosting
99+
runs-on: "ubuntu-latest"
100+
timeout-minutes: 20
101+
permissions:
102+
id-token: write
103+
pull-requests: write
104+
contents: read
105+
needs: prepare-env
106+
env:
107+
AWS_ROLE: ${{ needs.prepare-env.outputs.AWS_ROLE }}
108+
ENV: ${{ needs.prepare-env.outputs.ENV }}
109+
PROJECT_PREFIX: ${{needs.prepare-env.outputs.PROJECT_PREFIX}}
110+
ENVIRONMENT_BUCKET: ${{needs.prepare-env.outputs.ENVIRONMENT_BUCKET}}
111+
STATIC_HOSTING_BUCKET: ${{needs.prepare-env.outputs.STATIC_HOSTING_BUCKET}}
112+
DISTRIBUTION_ID: ${{needs.prepare-env.outputs.DISTRIBUTION_ID}}
113+
114+
steps:
115+
- name: "Checkout repository"
116+
uses: actions/checkout@v4
117+
118+
- name: Configure AWS credentials
119+
uses: aws-actions/configure-aws-credentials@v4
120+
with:
121+
role-to-assume: ${{ secrets[env.AWS_ROLE] }}
122+
aws-region: ${{ env.AWS_REGION }}
123+
124+
# - name: Sync S3 environment
125+
# id: sync-env
126+
# run: |
127+
# aws s3 cp s3://${ENVIRONMENT_BUCKET}/${SERVICE_NAME}/${ENV}.env ./.env
128+
129+
- uses: actions/setup-node@v3
130+
with:
131+
node-version: 18
132+
133+
- name: Run Npm Command
134+
run: |
135+
npm install
136+
npm run build
137+
138+
- name: Sync S3 files
139+
id: sync-js
140+
run: |
141+
ls
142+
aws s3 cp ./dist/umd/ s3://${STATIC_HOSTING_BUCKET}/ --recursive
143+
144+
- name: Invalidate CloudFront
145+
uses: chetan/[email protected]
146+
env:
147+
DISTRIBUTION: ${{ secrets[env.DISTRIBUTION_ID] }}
148+
PATHS: "/*"
149+
AWS_REGION: ${{ env.AWS_REGION }}
150+
151+
152+
153+
### slack alert
154+
155+
slack-notification:
156+
name: Slack Notification
157+
if: always()
158+
runs-on: 'ubuntu-latest'
159+
needs:
160+
- prepare-env
161+
- static-host
162+
env:
163+
SLACK_WEBHOOK_URL: ${{needs.prepare-env.outputs.SLACK_WEBHOOK_URL}}
164+
steps:
165+
- uses: technote-space/workflow-conclusion-action@v3
166+
- name: Update slack message body
167+
id: body
168+
run: |
169+
if [ '${{ env.WORKFLOW_CONCLUSION }}' == 'success' ]
170+
then
171+
echo "::set-output name=SLACK_MESSAGE::Success :white_check_mark:"
172+
elif [ '${{ env.WORKFLOW_CONCLUSION }}' == 'failure' ]
173+
then
174+
echo "::set-output name=SLACK_MESSAGE::Failed :x:"
175+
elif [ '${{ env.WORKFLOW_CONCLUSION }}' == 'cancelled' ]
176+
then
177+
echo "::set-output name=SLACK_MESSAGE::Cancelled :grey_exclamation:"
178+
fi
179+
- name: Slack Notification
180+
uses: rtCamp/action-slack-notify@v2
181+
env:
182+
SLACK_COLOR: ${{ env.WORKFLOW_CONCLUSION }} # or a specific color like 'good' or '#ff00ff'
183+
SLACK_ICON: https://w7.pngwing.com/pngs/464/659/png-transparent-devops-computer-icons-agile-software-development-others-miscellaneous-text-orange-thumbnail.png
184+
SLACK_MESSAGE: ${{ steps.body.outputs.SLACK_MESSAGE }}
185+
SLACK_TITLE: Build Status
186+
SLACK_FOOTER: '<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>'
187+
SLACK_USERNAME: Siren-alerts
188+
SLACK_WEBHOOK: ${{ secrets[env.SLACK_WEBHOOK_URL] }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test Suite
2+
3+
on:
4+
pull_request:
5+
# The branches below must be a subset of the branches above
6+
branches: [main, dev]
7+
8+
jobs:
9+
test-and-build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: [18.x]
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
with:
18+
ref: ${{ github.event.pull_request.head.sha }}
19+
fetch-depth: 0
20+
21+
- name: Use Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v2
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
26+
- name: Install dependencies
27+
run: npm install
28+
29+
- name: Linting
30+
run: npm run lint
31+
32+
- name: Test
33+
run: npm run test
34+
35+
- name: Build
36+
run: npm run build

0 commit comments

Comments
 (0)