From 2d344b1661c7ee4e4a2dbf772c6e4c19ff57e660 Mon Sep 17 00:00:00 2001 From: 9ho_Mac <77798814+ScriptBloxX@users.noreply.github.com> Date: Fri, 28 Mar 2025 11:06:57 +0700 Subject: [PATCH 1/2] add workflow & bot --- .github/dependabot.yml | 6 ++++++ .github/workflows/coverage.yml | 30 +++++++++++++++++++++++++++++ .github/workflows/lint-code.yml | 34 +++++++++++++++++++++++++++++++++ .github/workflows/node-ci.yml | 34 +++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/lint-code.yml create mode 100644 .github/workflows/node-ci.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..692bd58 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..bdcefb4 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,30 @@ +name: Code Coverage + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + coverage: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '14' + + - name: Install dependencies + run: npm install + + - name: Run tests and collect coverage + run: | + npm run test -- --coverage + npx codecov diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml new file mode 100644 index 0000000..920adc5 --- /dev/null +++ b/.github/workflows/lint-code.yml @@ -0,0 +1,34 @@ +name: Lint Code + +on: + push: + branches: + - main + - dev + - 'feature/*' + - 'bug/*' + pull_request: + branches: + - main + - dev + - 'feature/*' + - 'bug/*' + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Run ESLint + run: npx eslint . diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml new file mode 100644 index 0000000..3d5831d --- /dev/null +++ b/.github/workflows/node-ci.yml @@ -0,0 +1,34 @@ +name: Node.js CI + +on: + push: + branches: + - main + - dev + - 'feature/*' + - 'bug/*' + pull_request: + branches: + - main + - dev + - 'feature/*' + - 'bug/*' + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test From be6ef181dfe4214dcb6eebfae8bb33e73c432e08 Mon Sep 17 00:00:00 2001 From: 9ho_Mac <77798814+ScriptBloxX@users.noreply.github.com> Date: Fri, 28 Mar 2025 11:13:04 +0700 Subject: [PATCH 2/2] config --- .github/workflows/coverage.yml | 2 +- .../disable-deploy-for-new-branches.yml | 12 +++++-- .github/workflows/lint-code.yml | 34 ------------------- .github/workflows/node-ci.yml | 34 ------------------- 4 files changed, 11 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/lint-code.yml delete mode 100644 .github/workflows/node-ci.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index bdcefb4..4451f2e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '14' + node-version: '20' - name: Install dependencies run: npm install diff --git a/.github/workflows/disable-deploy-for-new-branches.yml b/.github/workflows/disable-deploy-for-new-branches.yml index 4b13544..809a3a9 100644 --- a/.github/workflows/disable-deploy-for-new-branches.yml +++ b/.github/workflows/disable-deploy-for-new-branches.yml @@ -37,6 +37,14 @@ jobs: git config --global user.name "github-actions" git config --global user.email "github-actions@github.com" git add vercel.json - git commit -m "Disable auto deploy for branch $BRANCH_NAME" - git push + + # Check if there are any changes to commit + if git diff --cached --quiet; then + echo "No changes to commit, skipping git commit." + else + git commit -m "Disable auto deploy for branch $BRANCH_NAME" + git push + fi + else + echo "Branch $BRANCH_NAME already exists in vercel.json, skipping." fi diff --git a/.github/workflows/lint-code.yml b/.github/workflows/lint-code.yml deleted file mode 100644 index 920adc5..0000000 --- a/.github/workflows/lint-code.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Lint Code - -on: - push: - branches: - - main - - dev - - 'feature/*' - - 'bug/*' - pull_request: - branches: - - main - - dev - - 'feature/*' - - 'bug/*' - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20' - - - name: Install dependencies - run: npm install - - - name: Run ESLint - run: npx eslint . diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml deleted file mode 100644 index 3d5831d..0000000 --- a/.github/workflows/node-ci.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Node.js CI - -on: - push: - branches: - - main - - dev - - 'feature/*' - - 'bug/*' - pull_request: - branches: - - main - - dev - - 'feature/*' - - 'bug/*' - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '20' - - - name: Install dependencies - run: npm install - - - name: Run tests - run: npm test