Skip to content

Commit

Permalink
feat(TU-3717): Initial version (#1)
Browse files Browse the repository at this point in the history
* feat(NOJIRA-123): Initial version

* chore: add github action for PR check, update configs

* fix: change types
- rename `payload` to `formId` for "edit" action
- change callback payload to object with `formId` prop
- attach click action via `addEventListener`

* Update README.md
Co-authored-by: Leandro Serafim <dev.serafim@gmail.com>

* feat: change each action to a separate method

* chore: add release github action and PR deploy-preview

* chore: Update README and gitignore file

---------

Co-authored-by: Leandro Serafim <dev.serafim@gmail.com>
  • Loading branch information
mathio and leandro-serafim authored Dec 4, 2023
1 parent 92dd907 commit 8215e56
Show file tree
Hide file tree
Showing 42 changed files with 7,956 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
max_line_length=120
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=true
insert_final_newline=true
indent_style=space
indent_size=2
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
commitlint.config.js
27 changes: 27 additions & 0 deletions .github/workflows/ci-standard-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI Standard Checks
on:
push:
branches:
- main
pull_request:
types:
- opened
- edited
- synchronize
- reopened
- ready_for_review
branches:
- main
jobs:
ci-standard-checks:
runs-on:
- ubuntu-latest
steps:
- name: Check Out Source Code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: CI Standard Checks
uses: Typeform/ci-standard-checks@v1
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
86 changes: 86 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Pull Request
on:
pull_request:
branches:
- main

jobs:
build-lint-test:
runs-on: ubuntu-latest
name: build-lint-test
steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Get yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
~/.cache
key: ${{ runner.os }}-repo-${{ github.event.pull_request.head.repo.full_name }}-node-20-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }}

- name: Install Node.js dependencies
# run when cache not found or PR is external (build fails for external PRs if dependencies are not installed)
if: steps.yarn-cache.outputs.cache-hit != 'true' || github.event.pull_request.head.repo.full_name != github.repository
run: yarn install --frozen-lockfile

- run: yarn dist
- run: yarn lint
- run: yarn test

deploy-preview:
runs-on: ubuntu-latest
name: deploy-preview
steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Get yarn cache
uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
~/.cache
key: ${{ runner.os }}-repo-${{ github.event.pull_request.head.repo.full_name }}-node-20-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }}

- name: Install Node.js dependencies
# run when cache not found or PR is external (build fails for external PRs if dependencies are not installed)
if: steps.yarn-cache.outputs.cache-hit != 'true' || github.event.pull_request.head.repo.full_name != github.repository
run: yarn install --frozen-lockfile

- run: yarn dist

# update registry and tokens with write access for releasing.
- run: rm ./.npmrc
- run: npm config set '//registry.npmjs.org/:_authToken' $NPM_TOKEN
- run: npm config set '//npm.pkg.github.com/:_authToken' $GH_TOKEN
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: npm config set @typeform:registry https://npm.pkg.github.com/

# install jarvis private package from github
- run: yarn add -W @typeform/jarvis
- run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private (the file is committed by semantic-release to bump version)

# deploy preview version of the package
- run: yarn release:aws --preview --notify-preview
env:
AWS_ASSETS_BUCKET: 'typeform-public-assets/btn'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
JARVIS_NOTIFY_PREVIEW_TEMPLATE: ${{ secrets.JARVIS_NOTIFY_PREVIEW_TEMPLATE }}
PUBLIC_CDN_URL: 'https://btn.typeform.com'
67 changes: 67 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Release

on:
push:
branches: [main]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20

- name: Get yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
~/.cache
key: ${{ runner.os }}-repo-${{ github.event.pull_request.head.repo.full_name }}-node-20-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/**.yml') }}

- name: Install Node.js dependencies
# run when cache not found or PR is external (build fails for external PRs if dependencies are not installed)
if: steps.yarn-cache.outputs.cache-hit != 'true' || github.event.pull_request.head.repo.full_name != github.repository
run: yarn install --frozen-lockfile

- run: yarn dist
env:
NODE_ENV: 'production'

# update registry and tokens with write access for releasing.
- run: rm ./.npmrc
- run: npm config set '//registry.npmjs.org/:_authToken' $NPM_TOKEN
- run: npm config set '//npm.pkg.github.com/:_authToken' $GH_TOKEN
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- run: npm config set @typeform:registry https://npm.pkg.github.com/

# install jarvis private package from github
- run: yarn add -W @typeform/jarvis
- run: git checkout HEAD -- package.json # do not save jarvis dependency to package.json because it is private (the file is committed by semantic-release to bump version)

- run: yarn release
env:
AWS_ASSETS_BUCKET: 'typeform-public-assets/btn'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_CLOUDFRONT_DIST: 'E3IUO95IYL1RI3'
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PUBLIC_CDN_URL: 'https://btn.typeform.com'
SEGMENT_WRITE_KEY: ${{ secrets.DEPLOYMENT_SEGMENT_WRITE_KEY }}

- uses: 8398a7/action-slack@v3
if: failure()
with:
status: ${{ job.status }}
fields: repo,message,commit,author,action
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# OSX and ide's folder attributes
.DS_Store
Thumbs.db
.cache
.project
.settings
.tmproj
*.esproj
nbproject
*.sublime-project
*.sublime-workspace
*.sublime-*
jsconfig.json
.vscode
.idea
.env

# project specific
node_modules
dist
7 changes: 7 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"hooks": {
"pre-commit": "yarn lint && yarn build",
"pre-push": "yarn test",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# override registry since this is a public repo
@typeform:registry=https://registry.yarnpkg.com
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Typeform/reach
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Typeform

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 8215e56

Please sign in to comment.