diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..7928c0d --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,10 @@ +name: Pull Request Check +on: + pull_request: + branches: + - dev/* + - master +jobs: + unit-tests: + name: Unit Tests + uses: ./.github/workflows/unit-tests.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..54eea83 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +name: Publish +on: + push: + branches: master +jobs: + unit-tests: + name: Unit Tests + uses: ./.github/workflows/unit-tests.yml + publish: + name: Publish + needs: unit-tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - name: Get package.json + id: get-package + run: echo PACKAGE=$(cat ./package.json) >> $GITHUB_OUTPUT + - name: Get package version + id: get-package-version + run: echo VERSION="${{ fromJson(steps.get-package.outputs.PACKAGE).version }}" >> $GITHUB_OUTPUT + - name: Install + run: npm ci + - name: Build + run: npm run build + - name: Publish + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + - name: Tag + run: | + git config --global user.name "ponlawat-w" + git config --global user.email "ponlawat_w@outlook.co.th" + git tag -fa ${{ steps.get-package-version.outputs.VERSION }} + git push --force origin ${{ steps.get-package-version.outputs.VERSION }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000..52b15e4 --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,19 @@ +name: Unit Tests +on: workflow_call +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Install + run: npm ci + - name: Test + run: npm run test diff --git a/README.md b/README.md index 382a1f8..c4c447d 100644 --- a/README.md +++ b/README.md @@ -110,55 +110,6 @@ mao.addInteraction(interaction); ### Using as CDN -```html - - - - - - - - -
- - - - - -``` +[HTML Example](./examples/index.html) --- diff --git a/examples/index.html b/examples/index.html index 3c50091..d9d4f2e 100644 --- a/examples/index.html +++ b/examples/index.html @@ -41,8 +41,7 @@
- - +