From f55efe91ab39ec02df818b6b52ed726ecb987325 Mon Sep 17 00:00:00 2001 From: David Nguyen Date: Thu, 2 Jul 2026 17:21:14 +0700 Subject: [PATCH] chore: bootstrap ci and deepsource config --- .deepsource.toml | 10 +++++++ .github/workflows/ci.yml | 37 +++++++++++++++++++++++ .github/workflows/pr-auto-approve.yml | 42 +++++++++++++++++++++++++-- .github/workflows/pr-closed.yml | 2 +- .github/workflows/release.yml | 14 +++++---- 5 files changed, 97 insertions(+), 8 deletions(-) create mode 100644 .deepsource.toml create mode 100644 .github/workflows/ci.yml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 0000000..a4e77d7 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,10 @@ +version = 1 + +[[analyzers]] +name = "javascript" + + [analyzers.meta] + plugins = ["react"] + +[[transformers]] +name = "prettier" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ee0bad3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + ci: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v7 + + - name: Enable Corepack + run: corepack enable + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 24.x + cache: yarn + + - name: Install dependencies + run: yarn install --immutable --mode=skip-build + + - name: Prepare WXT types + run: yarn exec wxt prepare + + - name: Build extension + run: yarn build diff --git a/.github/workflows/pr-auto-approve.yml b/.github/workflows/pr-auto-approve.yml index f5389de..f239576 100644 --- a/.github/workflows/pr-auto-approve.yml +++ b/.github/workflows/pr-auto-approve.yml @@ -6,6 +6,7 @@ on: permissions: pull-requests: write + issues: write jobs: approve: @@ -38,14 +39,51 @@ jobs: HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} GH_TOKEN: ${{secrets.EPLUS_BOT_TOKEN}} - - name: Approve pull request with comment - run: gh pr review --approve "$PR_NUMBER" --body "$APPROVAL_COMMENT" --repo "$GITHUB_REPOSITORY" + - name: Approve pull request + run: | + APPROVED_FOR_HEAD="$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \ + --paginate \ + --jq ".[] | select(.user.login == \"eplus-bot\" and .state == \"APPROVED\" and .commit_id == \"$HEAD_SHA\") | .id" \ + | tail -n 1)" + + if [ -z "$APPROVED_FOR_HEAD" ]; then + gh pr review --approve "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" + fi + env: + PR_NUMBER: ${{steps.pr.outputs.number}} + HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + GH_TOKEN: ${{secrets.EPLUS_BOT_TOKEN}} + + - name: Upsert CI approval comment + run: | + COMMENT_ID="$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ + --paginate \ + --jq ".[] | select(.user.login == \"eplus-bot\" and (.body | contains(\"$COMMENT_MARKER\"))) | .id" \ + | tail -n 1)" + + if [ -n "$COMMENT_ID" ]; then + gh api \ + --method PATCH \ + "repos/$GITHUB_REPOSITORY/issues/comments/$COMMENT_ID" \ + -f body="$APPROVAL_COMMENT" + else + gh api \ + --method POST \ + "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \ + -f body="$APPROVAL_COMMENT" + fi env: PR_NUMBER: ${{steps.pr.outputs.number}} + COMMENT_MARKER: "" APPROVAL_COMMENT: | + + ![CI passed](https://img.shields.io/badge/CI-passed-brightgreen) Approved by @eplus-bot after CI passed. + Updated: ${{ github.event.workflow_run.updated_at }} + Run attempt: #${{ github.event.workflow_run.run_attempt }} + CI run: ${{ github.event.workflow_run.html_url }} GH_TOKEN: ${{secrets.EPLUS_BOT_TOKEN}} diff --git a/.github/workflows/pr-closed.yml b/.github/workflows/pr-closed.yml index 678ae5b..783dab7 100644 --- a/.github/workflows/pr-closed.yml +++ b/.github/workflows/pr-closed.yml @@ -1,4 +1,4 @@ -name: 🎉 PR closed +name: PR closed on: pull_request_target: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5b1e20..7991482 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,11 +31,17 @@ jobs: - name: Setup Node.js with Yarn cache uses: actions/setup-node@v6 with: - node-version: 22.x + node-version: 24.x cache: "yarn" + - name: Enable Corepack + run: corepack enable + - name: Install dependencies - run: yarn install --frozen-lockfile + run: yarn install --immutable --mode=skip-build + + - name: Prepare WXT types + run: yarn exec wxt prepare - name: Build the extension run: | @@ -50,13 +56,11 @@ jobs: - name: Update CHANGELOG id: changelog uses: requarks/changelog-action@v1 - continue-on-error: true with: token: ${{ github.token }} tag: ${{ github.ref_name }} - name: Commit CHANGELOG.md - if: steps.changelog.outcome == 'success' uses: stefanzweifel/git-auto-commit-action@v7 with: branch: main @@ -76,7 +80,7 @@ jobs: - name: Submit to stores if: startsWith(github.ref, 'refs/tags/') run: | - yarn wxt submit \ + yarn exec wxt submit \ --chrome-zip .output/*-chrome.zip \ --firefox-zip .output/*-firefox.zip \ --firefox-sources-zip .output/*-sources.zip