diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4ed4482898..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,435 +0,0 @@ -# https://circleci.com/blog/persisting-data-in-workflows-when-to-use-caching-artifacts-and-workspaces/ - -version: 2.1 - -orbs: - codecov: codecov/codecov@4.1.0 - -workflows: - version: 2 - build-n-deploy: - jobs: - # The `build-branch` job will run only on the specified branches. - - build-branch: - filters: - branches: - only: - - v2 - # The `deploy-branch` job will run only on the specified branches. - - deploy-branch: - requires: - - build-branch - filters: - branches: - only: - - v2 - # The `build-pr` job will run on branches that have associated pull requests open. - - build-pr: - filters: - branches: - ignore: - - gh-pages - - v2 - # The `deploy-pr` job will run on branches that have associated pull requests open. - - deploy-pr: - requires: - - build-pr - filters: - branches: - ignore: - - gh-pages - - v2 - # The `build-tag` job will not run on all branches and will run only on the matched tags. - - build-tag: - filters: - branches: - ignore: /.*/ - tags: - only: - - /^@tonic-ui\/react@.*/ - # The `deploy-tag` job will not run on all branches and will run only on the matched tags. - - deploy-tag: - requires: - - build-tag - filters: - branches: - ignore: /.*/ - tags: - only: - - /^@tonic-ui\/react@.*/ - -# https://circleci.com/docs/2.0/executor-types/ -jobs: - build-branch: - docker: - - image: cimg/node:18.20 - steps: - - checkout - - run: - name: Setup environment - command: | - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export MATOMO_URL=//matomo.xdr.trendmicro.com" >> $BASH_ENV - echo "export MATOMO_CONTAINER_ID=N8rpl9LU" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=v2" >> $BASH_ENV - - run: - name: Check package version - command: | - git --version - node --version - npm --version - yarn --version - - run: - name: Install packages - command: | - yarn up - yarn install - - run: - name: Build & Test - command: | - echo "BASE_PATH=/tonic-ui/react/${TONIC_UI_REACT_DOCS_VERSION}" > packages/react-docs/.env.production - yarn build - yarn lint - yarn test - - codecov/upload: - file: ./packages/changelog-github/coverage/lcov.info - flags: changelog-github - - codecov/upload: - file: ./packages/codemod/coverage/lcov.info - flags: codemod - - codecov/upload: - file: ./packages/react/coverage/lcov.info - flags: react - - codecov/upload: - file: ./packages/react-base/coverage/lcov.info - flags: react-base - - codecov/upload: - file: ./packages/react-hooks/coverage/lcov.info - flags: react-hooks - - codecov/upload: - file: ./packages/react-icons/coverage/lcov.info - flags: react-icons - - codecov/upload: - file: ./packages/styled-system/coverage/lcov.info - flags: styled-system - - codecov/upload: - file: ./packages/theme/coverage/lcov.info - flags: theme - - codecov/upload: - file: ./packages/utils/coverage/lcov.info - flags: utils - - run: - name: Compress build artifacts - command: | - tar -zcvf ci.tar.gz --dereference --directory packages/react-docs/dist react - - persist_to_workspace: - # Must be an absolute path, or relative path from working_directory. - # This is a directory on the container which is taken to be the root directory of the workspace. - root: . - paths: - - ci.tar.gz - - build-pr: - docker: - - image: cimg/node:18.20 - steps: - - checkout - - run: - name: Setup environment - command: | - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_PULL_REQUEST_NUMBER=${CIRCLE_PULL_REQUEST##*/}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export MATOMO_URL=//matomo.xdr.trendmicro.com" >> $BASH_ENV - echo "export MATOMO_CONTAINER_ID=5ehpp7RV_staging_0f078a89d761f525ed18a6f5" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=pr-${CIRCLE_PULL_REQUEST##*/}" >> $BASH_ENV - - run: - name: Check package version - command: | - git --version - node --version - npm --version - yarn --version - - run: - name: Install packages - command: | - yarn up - yarn install - - run: - name: Build & Test - command: | - echo "BASE_PATH=/tonic-ui-demo/react/${TONIC_UI_REACT_DOCS_VERSION}" > packages/react-docs/.env.production - yarn build - yarn lint - yarn test - - codecov/upload: - file: ./packages/changelog-github/coverage/lcov.info - flags: changelog-github - - codecov/upload: - file: ./packages/codemod/coverage/lcov.info - flags: codemod - - codecov/upload: - file: ./packages/react/coverage/lcov.info - flags: react - - codecov/upload: - file: ./packages/react-base/coverage/lcov.info - flags: react-base - - codecov/upload: - file: ./packages/react-hooks/coverage/lcov.info - flags: react-hooks - - codecov/upload: - file: ./packages/react-icons/coverage/lcov.info - flags: react-icons - - codecov/upload: - file: ./packages/styled-system/coverage/lcov.info - flags: styled-system - - codecov/upload: - file: ./packages/theme/coverage/lcov.info - flags: theme - - codecov/upload: - file: ./packages/utils/coverage/lcov.info - flags: utils - - run: - name: Compress build artifacts - command: | - tar -zcvf ci.tar.gz --dereference --directory packages/react-docs/dist react - - persist_to_workspace: - # Must be an absolute path, or relative path from working_directory. - # This is a directory on the container which is taken to be the root directory of the workspace. - root: . - paths: - - ci.tar.gz - - scripts - - build-tag: - docker: - - image: cimg/node:18.20 - steps: - - checkout - - run: - name: Setup environment - command: | - TONIC_UI_PACKAGES_REACT_VERSION=$(cat packages/react/package.json \ - | grep version \ - | head -1 \ - | awk -F: '{ print $2 }' \ - | sed 's/[",]//g' \ - | tr -d '[[:space:]]') - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export MATOMO_URL=//matomo.xdr.trendmicro.com" >> $BASH_ENV - echo "export MATOMO_CONTAINER_ID=N8rpl9LU" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_PACKAGES_REACT_VERSION}" >> $BASH_ENV - - run: - name: Check package version - command: | - git --version - node --version - npm --version - yarn --version - - run: - name: Install packages - command: | - yarn up - yarn install - - run: - name: Build & Test - command: | - echo "BASE_PATH=/tonic-ui/react/${TONIC_UI_REACT_DOCS_VERSION}" > packages/react-docs/.env.production - yarn build - yarn lint - yarn test - - codecov/upload: - file: ./packages/changelog-github/coverage/lcov.info - flags: changelog-github - - codecov/upload: - file: ./packages/codemod/coverage/lcov.info - flags: codemod - - codecov/upload: - file: ./packages/react/coverage/lcov.info - flags: react - - codecov/upload: - file: ./packages/react-base/coverage/lcov.info - flags: react-base - - codecov/upload: - file: ./packages/react-hooks/coverage/lcov.info - flags: react-hooks - - codecov/upload: - file: ./packages/react-icons/coverage/lcov.info - flags: react-icons - - codecov/upload: - file: ./packages/styled-system/coverage/lcov.info - flags: styled-system - - codecov/upload: - file: ./packages/theme/coverage/lcov.info - flags: theme - - codecov/upload: - file: ./packages/utils/coverage/lcov.info - flags: utils - - run: - name: Compress build artifacts - command: | - tar -zcvf ci.tar.gz --dereference --directory packages/react-docs/dist react - - persist_to_workspace: - # Must be an absolute path, or relative path from working_directory. - # This is a directory on the container which is taken to be the root directory of the workspace. - root: . - paths: - - ci.tar.gz - - deploy-branch: - docker: - - image: cimg/node:18.20 - steps: - - run: - name: Configuration - command: | - git config --global user.email "no-reply@github.com" - git config --global user.name "ci-job" - npm config set loglevel warn - - checkout: - path: tonic-ui - - add_ssh_keys: - fingerprints: - - "92:e5:99:6a:e1:24:28:b6:fb:a4:33:9a:a1:b1:a7:c6" - - attach_workspace: - # Must be absolute path or relative path from working_directory - at: workspace - - run: - name: Setup environment - command: | - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=v2" >> $BASH_ENV - - run: - name: Extract build artifacts - command: | - mkdir -p dist - tar -zxvf workspace/ci.tar.gz --directory dist - - run: - name: Deploy to gh-pages - command: | - cd tonic-ui - git checkout gh-pages - rm -rf "react/${TONIC_UI_REACT_DOCS_VERSION}" - mkdir -p "react/${TONIC_UI_REACT_DOCS_VERSION}" - cp -af ../dist/react/** "react/${TONIC_UI_REACT_DOCS_VERSION}/" - git add "react/${TONIC_UI_REACT_DOCS_VERSION}" - git commit -m "[CI] Deploy '${CI_COMMIT_SHORT}' to 'gh-pages'" - git push origin gh-pages - - deploy-pr: - docker: - - image: cimg/node:18.20 - steps: - - run: - name: Configuration - command: | - git config --global user.email "no-reply@github.com" - git config --global user.name "ci-job" - npm config set loglevel warn - - checkout: - path: tonic-ui - - add_ssh_keys: - fingerprints: - - "73:b4:70:76:97:74:c2:f5:c9:bf:71:83:8c:a6:da:a6" - - attach_workspace: - # Must be absolute path or relative path from working_directory - at: workspace - - run: - name: Setup environment - command: | - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_PULL_REQUEST_NUMBER=${CIRCLE_PULL_REQUEST##*/}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export TONIC_UI_DEMO_REPO=tonic-ui-demo" >> $BASH_ENV - echo "export TONIC_UI_DEMO_REPO_URL=https://github.com/trendmicro-frontend/tonic-ui-demo.git" >> $BASH_ENV - echo "export TONIC_UI_DEMO_URL=https://trendmicro-frontend.github.io/tonic-ui-demo" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=pr-${CIRCLE_PULL_REQUEST##*/}" >> $BASH_ENV - - run: - name: Extract build artifacts - command: | - mkdir -p dist - tar -zxvf workspace/ci.tar.gz --directory dist - - run: - name: Deploy to gh-pages - command: | - git clone ${TONIC_UI_DEMO_REPO_URL} ${TONIC_UI_DEMO_REPO} - cd ${TONIC_UI_DEMO_REPO} - git checkout gh-pages - rm -rf "react/${TONIC_UI_REACT_DOCS_VERSION}" - mkdir -p "react/${TONIC_UI_REACT_DOCS_VERSION}" - cp -af ../dist/react/** "react/${TONIC_UI_REACT_DOCS_VERSION}/" - git add "react/${TONIC_UI_REACT_DOCS_VERSION}" - git commit -m "Deploy '${TONIC_UI_REACT_DOCS_VERSION}' to '${TONIC_UI_DEMO_REPO_URL}'" - GIT_LOG_LAST_COMMIT_DATE=`git log --pretty=%ci -n 1` - git push -u ${TONIC_UI_DEMO_REPO_URL} gh-pages - cd .. - yarn add file:./workspace/scripts/github-issue-comment-cli - npx github-issue-comment-cli --login-user trendmicro-frontend-bot --owner trendmicro-frontend --repo tonic-ui --issue-number ${CI_PULL_REQUEST_NUMBER} --comment "# Tonic UI Demo\n* ${GIT_LOG_LAST_COMMIT_DATE} The PR #${CI_PULL_REQUEST_NUMBER} (${CI_COMMIT}) has been deployed to ${TONIC_UI_DEMO_URL}/react/${TONIC_UI_REACT_DOCS_VERSION}/\n" - - deploy-tag: - docker: - - image: cimg/node:18.20 - steps: - - run: - name: Configuration - command: | - git config --global user.email "no-reply@github.com" - git config --global user.name "ci-job" - npm config set loglevel warn - - checkout: - path: tonic-ui - - add_ssh_keys: - fingerprints: - - "92:e5:99:6a:e1:24:28:b6:fb:a4:33:9a:a1:b1:a7:c6" - - attach_workspace: - # Must be absolute path or relative path from working_directory - at: workspace - - run: - name: Setup environment - command: | - TONIC_UI_PACKAGES_REACT_VERSION=$(cat tonic-ui/packages/react/package.json \ - | grep version \ - | head -1 \ - | awk -F: '{ print $2 }' \ - | sed 's/[",]//g' \ - | tr -d '[[:space:]]') - echo "export CI_BRANCH=${CIRCLE_BRANCH}" >> $BASH_ENV - echo "export CI_BUILD_NUMBER=${CIRCLE_BUILD_NUM}" >> $BASH_ENV - echo "export CI_COMMIT=${CIRCLE_SHA1}" >> $BASH_ENV - echo "export CI_COMMIT_SHORT=${CIRCLE_SHA1:0:8}" >> $BASH_ENV - echo "export CI_TAG=${CIRCLE_TAG}" >> $BASH_ENV - echo "export TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_PACKAGES_REACT_VERSION}" >> $BASH_ENV - - run: - name: Extract build artifacts - command: | - mkdir -p dist - tar -zxvf workspace/ci.tar.gz --directory dist - - run: - name: Deploy to gh-pages - command: | - cd tonic-ui - git checkout gh-pages - rm -rf "react/${TONIC_UI_REACT_DOCS_VERSION}" - mkdir -p "react/${TONIC_UI_REACT_DOCS_VERSION}" - cp -af ../dist/react/** "react/${TONIC_UI_REACT_DOCS_VERSION}/" - git add "react/${TONIC_UI_REACT_DOCS_VERSION}" - git commit -m "[CI] Deploy '${TONIC_UI_REACT_DOCS_VERSION}' to 'gh-pages' (tag='${CI_TAG}')" - git push origin gh-pages diff --git a/.github/workflows/algolia-search-indexing.yml b/.github/workflows/algolia-search-indexing.yml index 021ef729f2..8f42b9026b 100644 --- a/.github/workflows/algolia-search-indexing.yml +++ b/.github/workflows/algolia-search-indexing.yml @@ -17,9 +17,9 @@ jobs: matrix: node-version: [18.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Install yarn diff --git a/.github/workflows/changesets-release.yml b/.github/workflows/changesets-release.yml index 4d4eb9f8ea..a2fbd671b8 100644 --- a/.github/workflows/changesets-release.yml +++ b/.github/workflows/changesets-release.yml @@ -31,7 +31,7 @@ jobs: id: checkout uses: actions/checkout@v4 with: - # Ensure the full git history is available so that `changesets` can generate changelogs with the correct commits + # Fetch the entire Git history to ensure `Changesets` can generate changelogs with the correct commits fetch-depth: 0 - name: Setup Node id: setup-node diff --git a/.github/workflows/ci-branch.yml b/.github/workflows/ci-branch.yml new file mode 100644 index 0000000000..d3dbe45186 --- /dev/null +++ b/.github/workflows/ci-branch.yml @@ -0,0 +1,134 @@ +name: ci-branch + +on: + push: + branches: + - v2 + workflow_dispatch: + branches: + - v2 + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs + outputs: + TONIC_UI_REACT_DOCS_VERSION: ${{ steps.step_setup_env.outputs.TONIC_UI_REACT_DOCS_VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Fetch the entire Git history to access the latest tag release + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Check installed versions + run: | + git --version + node --version + npm --version + yarn --version + + - name: Configure environment variables + id: step_setup_env + run: | + TONIC_UI_REACT_VERSION=v2 + echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + echo "CI_COMMIT=${{ github.sha }}" >> $GITHUB_ENV + echo "MATOMO_URL=//matomo.xdr.trendmicro.com" >> $GITHUB_ENV + echo "MATOMO_CONTAINER_ID=N8rpl9LU" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_BASE_PATH=/tonic-ui/react-docs/${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + + # $GITHUB_OUTPUT is shared between all steps in a job + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_OUTPUT + + - name: Install packages + run: | + yarn up + yarn install + + - name: Build & Test + run: | + yarn build + yarn lint + yarn test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: | + ./packages/changelog-github/coverage/lcov.info + ./packages/codemod/coverage/lcov.info + ./packages/react/coverage/lcov.info + ./packages/react-base/coverage/lcov.info + ./packages/react-hooks/coverage/lcov.info + ./packages/react-icons/coverage/lcov.info + ./packages/styled-system/coverage/lcov.info + ./packages/theme/coverage/lcov.info + ./packages/utils/coverage/lcov.info + + - name: Prepare artifact + run: | + mkdir -p ${{ github.workspace }}/artifact + tar -zcvf ${{ github.workspace }}/artifact/react-docs.tar.gz --dereference --directory packages/react-docs/dist . + continue-on-error: true + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ci-artifact + path: | + artifact/react-docs.tar.gz + if-no-files-found: error + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: gh-pages + + - name: git config + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Configure environment variables + env: + TONIC_UI_REACT_DOCS_VERSION: ${{ needs.build.outputs.TONIC_UI_REACT_DOCS_VERSION }} + run: | + echo "CI_COMMIT=${{ github.sha }}" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_DOCS_VERSION}" >> $GITHUB_ENV + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ci-artifact + path: artifact + + - name: Extract artifact + run: | + mkdir -p artifact/react-docs + tar -zxvf artifact/react-docs.tar.gz --directory artifact/react-docs + + - name: Deploy to gh-pages + run: | + rm -rf "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + mkdir -p "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + cp -af artifact/react-docs/** "react-docs/${TONIC_UI_REACT_DOCS_VERSION}/" + git add "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + git commit -m "Deploy ${CI_COMMIT:0:8} to gh-pages [skip ci]" + git push origin gh-pages diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml new file mode 100644 index 0000000000..e3c1c1858e --- /dev/null +++ b/.github/workflows/ci-pr.yml @@ -0,0 +1,155 @@ +name: ci-pr + +on: + pull_request: + types: + - opened + - reopened + - synchronize + branches: + - v2 + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs + outputs: + TONIC_UI_REACT_DOCS_VERSION: ${{ steps.step_setup_env.outputs.TONIC_UI_REACT_DOCS_VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Fetch the entire Git history to access the latest tag release + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Check installed versions + run: | + git --version + node --version + npm --version + yarn --version + + - name: Configure environment variables + id: step_setup_env + run: | + TONIC_UI_REACT_VERSION=pr-${{ github.event.number }} + echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + echo "CI_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + echo "CI_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV + echo "MATOMO_URL=//matomo.xdr.trendmicro.com" >> $GITHUB_ENV + echo "MATOMO_CONTAINER_ID=N8rpl9LU" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_BASE_PATH=/tonic-ui-demo/react-docs/${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + + # $GITHUB_OUTPUT is shared between all steps in a job + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_OUTPUT + + - name: Install packages + run: | + yarn up + yarn install + + - name: Build & Test + run: | + yarn build + yarn lint + yarn test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: | + ./packages/changelog-github/coverage/lcov.info + ./packages/codemod/coverage/lcov.info + ./packages/react/coverage/lcov.info + ./packages/react-base/coverage/lcov.info + ./packages/react-hooks/coverage/lcov.info + ./packages/react-icons/coverage/lcov.info + ./packages/styled-system/coverage/lcov.info + ./packages/theme/coverage/lcov.info + ./packages/utils/coverage/lcov.info + + - name: Prepare artifact + run: | + mkdir -p ${{ github.workspace }}/artifact + tar -zcvf ${{ github.workspace }}/artifact/react-docs.tar.gz --dereference --directory packages/react-docs/dist . + cp -af scripts/github-issue-comment-cli ${{ github.workspace }}/artifact/ + continue-on-error: true + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ci-artifact + path: | + artifact/react-docs.tar.gz + artifact/github-issue-comment-cli + if-no-files-found: error + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: trendmicro-frontend/tonic-ui-demo + ref: gh-pages + ssh-key: ${{ secrets.TONIC_UI_DEMO_SSH_PRIVATE_KEY }} + + - name: git config + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Configure environment variables + env: + TONIC_UI_REACT_DOCS_VERSION: ${{ needs.build.outputs.TONIC_UI_REACT_DOCS_VERSION }} + run: | + echo "CI_COMMIT=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV + echo "CI_PULL_REQUEST_NUMBER=${{ github.event.number }}" >> $GITHUB_ENV + echo "TONIC_UI_DEMO_PAGES_URL=https://trendmicro-frontend.github.io/tonic-ui-demo" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_DOCS_VERSION}" >> $GITHUB_ENV + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ci-artifact + path: artifact + + - name: Extract artifact + run: | + mkdir -p artifact/react-docs + tar -zxvf artifact/react-docs.tar.gz --directory artifact/react-docs + + - name: Deploy to gh-pages + run: | + rm -rf "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + mkdir -p "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + cp -af artifact/react-docs/** "react-docs/${TONIC_UI_REACT_DOCS_VERSION}/" + git add "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + git commit -m "Deploy ${TONIC_UI_REACT_DOCS_VERSION} to gh-pages [skip ci]" + git push origin gh-pages + GIT_LOG_LAST_COMMIT_DATE=`git log --pretty=%ci -n 1` + yarn add file:./artifact/github-issue-comment-cli + npx github-issue-comment-cli \ + --token ${{ secrets.TONIC_UI_PR_ACCESS_TOKEN }} \ + --pattern "## Tonic UI Demo" \ + --owner trendmicro-frontend \ + --repo tonic-ui \ + --issue-number ${CI_PULL_REQUEST_NUMBER} \ + --comment "## Tonic UI Demo\nOn ${GIT_LOG_LAST_COMMIT_DATE}, PR #${CI_PULL_REQUEST_NUMBER} (${CI_COMMIT}) was successfully deployed. You can view it at the following link:\n${TONIC_UI_DEMO_PAGES_URL}/react-docs/${TONIC_UI_REACT_DOCS_VERSION}/\n" diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml new file mode 100644 index 0000000000..31cd1d6d1d --- /dev/null +++ b/.github/workflows/ci-publish.yml @@ -0,0 +1,37 @@ +name: ci-publish + +on: + workflow_call: + workflow_dispatch: + branches: + - v2 + +permissions: + contents: write + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Fetch the entire Git history to access the latest tag release + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Install packages + run: | + yarn up + yarn install + + - name: Publish packages + run: | + yarn ci-publish diff --git a/.github/workflows/ci-tag.yml b/.github/workflows/ci-tag.yml new file mode 100644 index 0000000000..773bf28db4 --- /dev/null +++ b/.github/workflows/ci-tag.yml @@ -0,0 +1,131 @@ +name: ci-tag + +on: + push: + tags: + - '@tonic-ui/react@*' + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs + outputs: + TONIC_UI_REACT_DOCS_VERSION: ${{ steps.step_setup_env.outputs.TONIC_UI_REACT_DOCS_VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # Fetch the entire Git history to access the latest tag release + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18 + + - name: Check installed versions + run: | + git --version + node --version + npm --version + yarn --version + + - name: Configure environment variables + id: step_setup_env + run: | + TONIC_UI_REACT_VERSION=$(node -p "require('./packages/react/package.json').version") + echo "CI_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + echo "CI_COMMIT=${{ github.sha }}" >> $GITHUB_ENV + echo "MATOMO_URL=//matomo.xdr.trendmicro.com" >> $GITHUB_ENV + echo "MATOMO_CONTAINER_ID=N8rpl9LU" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_BASE_PATH=/tonic-ui/react-docs/${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_ENV + + # $GITHUB_OUTPUT is shared between all steps in a job + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_VERSION}" >> $GITHUB_OUTPUT + + - name: Install packages + run: | + yarn up + yarn install + + - name: Build & Test + run: | + yarn build + yarn lint + yarn test + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + files: | + ./packages/changelog-github/coverage/lcov.info + ./packages/codemod/coverage/lcov.info + ./packages/react/coverage/lcov.info + ./packages/react-base/coverage/lcov.info + ./packages/react-hooks/coverage/lcov.info + ./packages/react-icons/coverage/lcov.info + ./packages/styled-system/coverage/lcov.info + ./packages/theme/coverage/lcov.info + ./packages/utils/coverage/lcov.info + + - name: Prepare artifact + run: | + mkdir -p ${{ github.workspace }}/artifact + tar -zcvf ${{ github.workspace }}/artifact/react-docs.tar.gz --dereference --directory packages/react-docs/dist . + continue-on-error: true + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ci-artifact + path: | + artifact/react-docs.tar.gz + if-no-files-found: error + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }} + ref: gh-pages + + - name: git config + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Configure environment variables + env: + TONIC_UI_REACT_DOCS_VERSION: ${{ needs.build.outputs.TONIC_UI_REACT_DOCS_VERSION }} + run: | + echo "CI_COMMIT=${{ github.sha }}" >> $GITHUB_ENV + echo "TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_DOCS_VERSION}" >> $GITHUB_ENV + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ci-artifact + path: artifact + + - name: Extract artifact + run: | + mkdir -p artifact/react-docs + tar -zxvf artifact/react-docs.tar.gz --directory artifact/react-docs + + - name: Deploy to gh-pages + run: | + rm -rf "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + mkdir -p "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + cp -af artifact/react-docs/** "react-docs/${TONIC_UI_REACT_DOCS_VERSION}/" + git add "react-docs/${TONIC_UI_REACT_DOCS_VERSION}" + git commit -m "Deploy ${CI_COMMIT:0:8} to gh-pages [skip ci]" + git push origin gh-pages diff --git a/.github/workflows/update-yarn-lock-file.yml b/.github/workflows/update-yarn-lock-file.yml index 303ef04aae..73abfa1e4b 100644 --- a/.github/workflows/update-yarn-lock-file.yml +++ b/.github/workflows/update-yarn-lock-file.yml @@ -22,9 +22,9 @@ jobs: matrix: node-version: [18.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Install yarn diff --git a/packages/react-docs/.env b/packages/react-docs/.env index 4eb835daea..c48587c497 100644 --- a/packages/react-docs/.env +++ b/packages/react-docs/.env @@ -1,2 +1 @@ ASSET_PREFIX= -BASE_PATH= diff --git a/packages/react-docs/.env.production b/packages/react-docs/.env.production index c8c82aa7d9..c48587c497 100644 --- a/packages/react-docs/.env.production +++ b/packages/react-docs/.env.production @@ -1,2 +1 @@ ASSET_PREFIX= -BASE_PATH=/tonic-ui diff --git a/packages/react-docs/components/Header.js b/packages/react-docs/components/Header.js index 199b2bf7a0..49c6bbb557 100644 --- a/packages/react-docs/components/Header.js +++ b/packages/react-docs/components/Header.js @@ -32,11 +32,11 @@ import persistColorMode from '../utils/persist-color-mode'; import SearchButton from './SearchButton'; import InstantSearchModal from './InstantSearchModal'; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const GITHUB_REPO_URL = 'https://github.com/trendmicro-frontend/tonic-ui'; -const TONIC_UI_REACT_DOCS_ROOT = ensureString(process.env.TONIC_UI_REACT_DOCS_ROOT); +const TONIC_UI_REACT_DOCS_URL = ensureString(process.env.TONIC_UI_REACT_DOCS_URL); // The TONIC_UI_REACT_DOCS_VERSION environment variable might be one of: latest, pr-, or version (e.g. 0.1.0) for a tag release const TONIC_UI_REACT_DOCS_VERSION = ensureString(process.env.TONIC_UI_REACT_DOCS_VERSION); @@ -44,15 +44,15 @@ const TONIC_UI_REACT_DOCS_VERSION = ensureString(process.env.TONIC_UI_REACT_DOCS const versionMap = { 'v2': { label: 'v2', - url: `${TONIC_UI_REACT_DOCS_ROOT}/v2/getting-started`, + url: `${TONIC_UI_REACT_DOCS_URL}/v2/getting-started`, }, 'v1': { label: 'v1', - url: `${TONIC_UI_REACT_DOCS_ROOT}/v1/getting-started`, + url: `${TONIC_UI_REACT_DOCS_URL}/v1/getting-started`, }, 'v0': { label: 'v0', - url: `${TONIC_UI_REACT_DOCS_ROOT}/v0/getting-started`, + url: `${TONIC_UI_REACT_DOCS_URL}/v0/getting-started`, }, }; diff --git a/packages/react-docs/components/Sidebar.js b/packages/react-docs/components/Sidebar.js index 88d138dec5..27c8e416b1 100644 --- a/packages/react-docs/components/Sidebar.js +++ b/packages/react-docs/components/Sidebar.js @@ -41,7 +41,7 @@ const isElementInViewport = (el) => { ); }; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const Sidebar = forwardRef(( { diff --git a/packages/react-docs/next.config.mjs b/packages/react-docs/next.config.mjs index 7889e4b98e..1389eeea41 100644 --- a/packages/react-docs/next.config.mjs +++ b/packages/react-docs/next.config.mjs @@ -294,9 +294,8 @@ plugins.push(withSVGR); const initialNextConfig = { env: { - BASE_PATH: process.env.BASE_PATH, // CI - CI_COMMIT_SHORT: process.env.CI_COMMIT_SHORT, + CI_COMMIT: process.env.CI_COMMIT, CI_PULL_REQUEST_NUMBER: process.env.CI_PULL_REQUEST_NUMBER, // Content Security Policy NONCE: randomBytes(16).toString('base64'), @@ -308,10 +307,11 @@ const initialNextConfig = { ALGOLIA_SEARCH_API_KEY: 'c87cfe40f6ec7c43d4caf4316afd1816', ALGOLIA_INDEX_NAME: 'tonic-ui-v2', // common - TONIC_UI_REPO_ROOT: process.env.TONIC_UI_REPO_ROOT, - TONIC_UI_REACT_DOCS_ROOT: process.env.TONIC_UI_REACT_DOCS_ROOT, - TONIC_UI_REACT_DOCS_VERSION: process.env.TONIC_UI_REACT_DOCS_VERSION, // see `.circleci/config.yml` + TONIC_UI_REACT_DOCS_BASE_PATH: process.env.TONIC_UI_REACT_DOCS_BASE_PATH, + TONIC_UI_REACT_DOCS_URL: process.env.TONIC_UI_REACT_DOCS_URL, + TONIC_UI_REACT_DOCS_VERSION: process.env.TONIC_UI_REACT_DOCS_VERSION, TONIC_UI_REACT_PACKAGE_VERSION: process.env.TONIC_UI_REACT_PACKAGE_VERSION, + TONIC_UI_REPO_ROOT: process.env.TONIC_UI_REPO_ROOT, // v2 TONIC_UI_V2_BRANCH: process.env.TONIC_UI_V2_BRANCH, TONIC_UI_V2_DOCUMENTATION: process.env.TONIC_UI_V2_DOCUMENTATION, @@ -337,8 +337,8 @@ const initialNextConfig = { TONIC_UI_V0_RELEASE_DOCUMENTATION: process.env.TONIC_UI_V0_RELEASE_DOCUMENTATION, TONIC_UI_V0_RELEASE_NOTES: process.env.TONIC_UI_V0_RELEASE_NOTES, }, - basePath: process.env.BASE_PATH, - distDir: process.env.NODE_ENV === 'production' ? 'dist/react' : 'build', + basePath: process.env.TONIC_UI_REACT_DOCS_BASE_PATH, + distDir: process.env.NODE_ENV === 'production' ? 'dist' : 'build', output: process.env.NODE_ENV === 'production' ? 'export' : 'standalone', pageExtensions: ['page.js', 'page.mdx'], }; diff --git a/packages/react-docs/pages/_document.page.js b/packages/react-docs/pages/_document.page.js index e578167426..5fdca731c1 100644 --- a/packages/react-docs/pages/_document.page.js +++ b/packages/react-docs/pages/_document.page.js @@ -2,7 +2,7 @@ import { ensureString } from 'ensure-type'; import React from 'react'; import Document, { Html, Head, Main, NextScript } from 'next/document'; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const MATOMO_URL = ensureString(process.env.MATOMO_URL); const MATOMO_CONTAINER_ID = ensureString(process.env.MATOMO_CONTAINER_ID); const NONCE = ensureString(process.env.NONCE); diff --git a/packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js b/packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js index 79793f42f8..b713f84d89 100644 --- a/packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js +++ b/packages/react-docs/pages/getting-started/usage/components/AnimatedCube.js @@ -4,7 +4,7 @@ import { MoonIcon, SunIcon } from '@tonic-ui/react-icons'; import { ensureString } from 'ensure-type'; import React, { useContext } from 'react'; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const cubeSpin = keyframes` from { transform: rotateY(360deg); } diff --git a/packages/react-docs/pages/index.page.js b/packages/react-docs/pages/index.page.js index 6d85cd2ce0..a5d676b9a4 100644 --- a/packages/react-docs/pages/index.page.js +++ b/packages/react-docs/pages/index.page.js @@ -63,7 +63,7 @@ import GitHubIcon from '../icons/GitHubIcon'; import { open as openInCodeSandbox } from '../sandbox/codesandbox'; import persistColorMode from '../utils/persist-color-mode'; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const GITHUB_REPO_URL = 'https://github.com/trendmicro-frontend/tonic-ui'; diff --git a/packages/react-docs/pages/patterns/notification/notification-center.js b/packages/react-docs/pages/patterns/notification/notification-center.js index cf7f2bf133..436096b0b0 100644 --- a/packages/react-docs/pages/patterns/notification/notification-center.js +++ b/packages/react-docs/pages/patterns/notification/notification-center.js @@ -25,7 +25,7 @@ import { formatDistance, formatISO, startOfToday, subDays, subMinutes, subSecond import { ensureString } from 'ensure-type'; import React, { useEffect } from 'react'; -const BASE_PATH = ensureString(process.env.BASE_PATH); +const BASE_PATH = ensureString(process.env.TONIC_UI_REACT_DOCS_BASE_PATH); const notifications = [ { diff --git a/packages/react-docs/sandbox/codesandbox.js b/packages/react-docs/sandbox/codesandbox.js index 981bc58954..5abca60651 100644 --- a/packages/react-docs/sandbox/codesandbox.js +++ b/packages/react-docs/sandbox/codesandbox.js @@ -5,7 +5,7 @@ import pkg from '../package.json'; const resolveDependencies = (contents) => { const getTonicUIPackageVersion = (packageName, defaultPackageVersion = 'latest') => { - const commitShort = process.env.CI_PULL_REQUEST_NUMBER ? process.env.CI_COMMIT_SHORT : undefined; + const commitShort = process.env.CI_PULL_REQUEST_NUMBER ? ensureString(process.env.CI_COMMIT).substring(0, 8) : undefined; if (!commitShort) { return defaultPackageVersion; } diff --git a/packages/react-docs/tonic-ui.env b/packages/react-docs/tonic-ui.env index 7854ceefed..b286ffe66b 100755 --- a/packages/react-docs/tonic-ui.env +++ b/packages/react-docs/tonic-ui.env @@ -1,33 +1,34 @@ #!/usr/bin/env bash -export TONIC_UI_REPO_ROOT=https://github.com/trendmicro-frontend/tonic-ui -export TONIC_UI_REACT_DOCS_ROOT=https://trendmicro-frontend.github.io/tonic-ui/react +export TONIC_UI_REACT_DOCS_BASE_PATH=${TONIC_UI_REACT_DOCS_BASE_PATH} +export TONIC_UI_REACT_DOCS_URL=https://trendmicro-frontend.github.io/tonic-ui/react-docs export TONIC_UI_REACT_DOCS_VERSION=${TONIC_UI_REACT_DOCS_VERSION:-v2-dev} export TONIC_UI_REACT_PACKAGE_VERSION=$(node -p "require('../react/package.json').version") +export TONIC_UI_REPO_ROOT=https://github.com/trendmicro-frontend/tonic-ui # v2 export TONIC_UI_V2_BRANCH=v2 -export TONIC_UI_V2_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/v2 +export TONIC_UI_V2_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/v2 export TONIC_UI_V2_SOURCE_CODE=${TONIC_UI_REPO_ROOT}/tree/${TONIC_UI_V2_BRANCH} export TONIC_UI_V2_TAGNAME=$(git -c 'versionsort.suffix=-' tag --list '@tonic-ui/react@2.*' --sort="-version:refname" | head -n 1) export TONIC_UI_V2_RELEASE_VERSION=$(echo $TONIC_UI_V2_TAGNAME | awk -F@ '{ print $3 }') -export TONIC_UI_V2_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/${TONIC_UI_V2_RELEASE_VERSION} +export TONIC_UI_V2_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/${TONIC_UI_V2_RELEASE_VERSION} export TONIC_UI_V2_RELEASE_NOTES=${TONIC_UI_REPO_ROOT}/releases/tag/${TONIC_UI_V2_TAGNAME} # v1 export TONIC_UI_V1_BRANCH=v1 -export TONIC_UI_V1_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/v1 +export TONIC_UI_V1_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/v1 export TONIC_UI_V1_SOURCE_CODE=${TONIC_UI_REPO_ROOT}/tree/${TONIC_UI_V1_BRANCH} export TONIC_UI_V1_TAGNAME=$(git -c 'versionsort.suffix=-' tag --list '@tonic-ui/react@1.*' --sort="-version:refname" | head -n 1) export TONIC_UI_V1_RELEASE_VERSION=$(echo $TONIC_UI_V1_TAGNAME | awk -F@ '{ print $3 }') -export TONIC_UI_V1_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/${TONIC_UI_V1_RELEASE_VERSION} +export TONIC_UI_V1_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/${TONIC_UI_V1_RELEASE_VERSION} export TONIC_UI_V1_RELEASE_NOTES=${TONIC_UI_REPO_ROOT}/releases/tag/${TONIC_UI_V1_TAGNAME} # v0 export TONIC_UI_V0_BRANCH=v0 -export TONIC_UI_V0_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/v0 +export TONIC_UI_V0_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/v0 export TONIC_UI_V0_SOURCE_CODE=${TONIC_UI_REPO_ROOT}/tree/${TONIC_UI_V0_BRANCH} export TONIC_UI_V0_TAGNAME=$(git -c 'versionsort.suffix=-' tag --list '@trendmicro/react-styled-ui@0.*' --sort="-version:refname" | head -n 1) export TONIC_UI_V0_RELEASE_VERSION=$(echo $TONIC_UI_V0_TAGNAME | awk -F@ '{ print $3 }') -export TONIC_UI_V0_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_ROOT}/${TONIC_UI_V0_RELEASE_VERSION} +export TONIC_UI_V0_RELEASE_DOCUMENTATION=${TONIC_UI_REACT_DOCS_URL}/${TONIC_UI_V0_RELEASE_VERSION} export TONIC_UI_V0_RELEASE_NOTES=${TONIC_UI_REPO_ROOT}/releases/tag/${TONIC_UI_V0_TAGNAME} diff --git a/scripts/github-issue-comment-cli/bin/cli.js b/scripts/github-issue-comment-cli/bin/cli.js index 6f7dde69c8..88350fd582 100755 --- a/scripts/github-issue-comment-cli/bin/cli.js +++ b/scripts/github-issue-comment-cli/bin/cli.js @@ -1,15 +1,19 @@ #!/usr/bin/env node -const _find = require('lodash.find'); const github = require('octonode'); const yargs = require('yargs'); const { hideBin } = require('yargs/helpers') const argv = yargs(hideBin(process.argv)) - .option('login-user', { + .option('token', { + demandOption: false, + type: 'string', + description: 'GitHub personal access token for authentication. If not provided, the action will use the default GitHub token available in the environment.', + }) + .option('pattern', { demandOption: true, type: 'string', - description: 'The login user name of the GitHub account', + description: 'The string pattern to search for within the PR', }) .option('owner', { demandOption: true, @@ -29,11 +33,11 @@ const argv = yargs(hideBin(process.argv)) .option('comment', { demandOption: true, type: 'string', - description: 'The comment to create or update', + description: 'The issue comment', }) .argv; const commentWithLineBreaks = String(argv.comment || '').replace(/\\n/g, '\n'); -const client = github.client(process.env.GH_TOKEN); +const client = github.client(argv.token || process.env.GH_TOKEN); const ghissue = client.issue(`${argv.owner}/${argv.repo}`, argv.issueNumber); ghissue.comments((err, result) => { @@ -43,7 +47,11 @@ ghissue.comments((err, result) => { } const comments = result; - const comment = _find(comments, { user: { login: argv.loginUser } }); + const comment = comments.find(comment => { + if (comment.body.includes(argv.pattern)) { + return true; + } + }); if (!comment) { ghissue.createComment({ body: commentWithLineBreaks }, (err, result) => { diff --git a/scripts/github-issue-comment-cli/package.json b/scripts/github-issue-comment-cli/package.json index 285403c0ca..bbc0654124 100644 --- a/scripts/github-issue-comment-cli/package.json +++ b/scripts/github-issue-comment-cli/package.json @@ -4,7 +4,6 @@ "version": "1.0.0", "bin": "./bin/cli.js", "dependencies": { - "lodash.find": "^4.6.0", "octonode": "^0.10.2", "yargs": "^17.3.1" }