Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions .github/workflows/check-db.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
name: check-db

on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
check-db:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v4
with:
cache: 'pnpm'

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Start Service
run: pnpm run dev &

- name: Update api.json
run: pnpm run api:download

- name: Check Diff
run: |
IS_DIFF=$(if git status | grep -q "packages/scripts/api.json"; then echo "true"; else echo "false"; fi)
echo "IS_DIFF: $IS_DIFF"
if [[ $IS_DIFF == 'true' ]]; then
git diff packages/scripts/api.json
echo "TDesign.db and api.json data inconsistency. Workflow will fail."
exit 1
fi
check-db:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6

- uses: pnpm/action-setup@v5

- uses: actions/setup-node@v6
with:
cache: 'pnpm'

- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Start Service
run: pnpm run dev &

- name: Update api.json
run: pnpm run api:download

- name: Check Diff
run: |
IS_DIFF=$(if git status | grep -q "packages/scripts/api.json"; then echo "true"; else echo "false"; fi)
echo "IS_DIFF: $IS_DIFF"
if [[ $IS_DIFF == 'true' ]]; then
git diff packages/scripts/api.json
echo "TDesign.db and api.json data inconsistency. Workflow will fail."
exit 1
fi
186 changes: 93 additions & 93 deletions .github/workflows/pr-comment-ci.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
name: pr-comment-ci

on:
issue_comment:
types: [created]
issue_comment:
types: [created]

jobs:
check:
runs-on: ubuntu-latest
outputs:
next_action: ${{ steps.get-action.outputs.next_action }}
if: ${{ github.event.issue.pull_request }}
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: |
.github/CODEOWNERS
sparse-checkout-cone-mode: false
- uses: actions/github-script@v7
id: get-action
with:
script: |
const user = context.payload.comment.user.login
core.debug(`user: ${user}`)
check:
runs-on: ubuntu-latest
outputs:
next_action: ${{ steps.get-action.outputs.next_action }}
if: ${{ github.event.issue.pull_request }}
steps:
- uses: actions/checkout@v6
with:
sparse-checkout: |
.github/CODEOWNERS
sparse-checkout-cone-mode: false
- uses: actions/github-script@v8
id: get-action
with:
script: |
const user = context.payload.comment.user.login
core.debug(`user: ${user}`)

const fs = require('fs')
const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8')
core.debug(`CODEOWNERS: ${CODEOWNERS}`)
const fs = require('fs')
const CODEOWNERS = fs.readFileSync('.github/CODEOWNERS', 'utf8')
core.debug(`CODEOWNERS: ${CODEOWNERS}`)

let isReviewer = false;
CODEOWNERS.match(/@\w+/g).forEach((owner) => {
if (owner === `@${user}`) {
isReviewer = true
}
})
let isReviewer = false;
CODEOWNERS.match(/@\w+/g).forEach((owner) => {
if (owner === `@${user}`) {
isReviewer = true
}
})

let next_action = ''
if (isReviewer) {
const body = context.payload.comment.body
core.info(`body: ${body}`)
if (body.startsWith('/resolve-conflict')) {
next_action='resolve-conflict'
}
if(next_action){
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket',
})
}
} else {
core.warning('You are not collaborator');
}
core.info(`next_action: ${next_action}`)
core.setOutput('next_action', next_action)

resolve-conflict:
needs: check
runs-on: ubuntu-latest
if: ${{ needs.check.outputs.next_action == 'resolve-conflict' }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
fetch-depth: 0
- name: gh checkout pr
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}
let next_action = ''
if (isReviewer) {
const body = context.payload.comment.body
core.info(`body: ${body}`)
if (body.startsWith('/resolve-conflict')) {
next_action='resolve-conflict'
}
if(next_action){
await github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket',
})
}
} else {
core.warning('You are not collaborator');
}
core.info(`next_action: ${next_action}`)
core.setOutput('next_action', next_action)

- uses: pnpm/action-setup@v4
resolve-conflict:
needs: check
runs-on: ubuntu-latest
if: ${{ needs.check.outputs.next_action == 'resolve-conflict' }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.PERSONAL_TOKEN }}
fetch-depth: 0
- name: gh checkout pr
env:
GH_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
run: gh pr checkout ${{ github.event.issue.number }}

- uses: actions/setup-node@v4
with:
cache: 'pnpm'
- uses: pnpm/action-setup@v5

- name: Install Dependencies
run: pnpm install --frozen-lockfile
- uses: actions/setup-node@v6
with:
cache: 'pnpm'

- name: Merge main
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git merge main --no-commit || true

- name: Resolve conflict
run: |
git status
conflict_count=$(git status | grep -c 'both modified:') || true
db_conflict=$(git status | grep 'both modified:' | grep -c 'db/TDesign.db') || true
echo "conflict_count $conflict_count"
echo "db_conflict $db_conflict"
- name: Install Dependencies
run: pnpm install --frozen-lockfile

if [ "$conflict_count" -eq "$db_conflict" ]&&[ "$conflict_count" -eq "1" ]; then
git checkout --theirs db/TDesign.db
git add db/TDesign.db
git status
nohup pnpm run dev &
sleep 10
pnpm api:upload
git commit -am "chore: resolve conflict"
git push
else
echo "Condition not established."
fi
- name: Merge main
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git merge main --no-commit || true

- name: Resolve conflict
run: |
git status
conflict_count=$(git status | grep -c 'both modified:') || true
db_conflict=$(git status | grep 'both modified:' | grep -c 'db/TDesign.db') || true
echo "conflict_count $conflict_count"
echo "db_conflict $db_conflict"

if [ "$conflict_count" -eq "$db_conflict" ]&&[ "$conflict_count" -eq "1" ]; then
git checkout --theirs db/TDesign.db
git add db/TDesign.db
git status
nohup pnpm run dev &
sleep 10
pnpm api:upload
git commit -am "chore: resolve conflict"
git push
else
echo "Condition not established."
fi
4 changes: 2 additions & 2 deletions .github/workflows/pr-spell-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ name: pr-spell-check
on: [pull_request]

jobs:
run:
uses: TDesignOteam/workflows/.github/workflows/spell-check.yml@main
run:
uses: TDesignOteam/workflows/.github/workflows/spell-check.yml@main
65 changes: 32 additions & 33 deletions .github/workflows/sync-to-cnb.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
name: sync-to-cnb
on:
- push
- delete
on:
- push
- delete

jobs:
sync-push:
if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Sync to CNB Repository
run: |
docker run --rm \
-v ${{ github.workspace }}:${{ github.workspace }} \
-w ${{ github.workspace }} \
-e PLUGIN_TARGET_URL="https://cnb.cool/tencent/tdesign/tdesign-api.git" \
-e PLUGIN_AUTH_TYPE="https" \
-e PLUGIN_USERNAME="cnb" \
-e PLUGIN_PASSWORD=${{ secrets.CNB_TOKEN }} \
-e PLUGIN_FORCE="true" \
tencentcom/git-sync
sync-push:
if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

sync-delete-branch:
if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'delete' && github.event.ref_type == 'branch' }}
runs-on: ubuntu-latest
steps:
- uses: TDesignOteam//tdesign-pr-trigger-action@develop
with:
repo: 'tencent/tdesign/tdesign-api'
token: ${{ secrets.CNB_TOKEN }}
branch: ${{ github.event.ref }}
trigger: '/delete-cnb-branch'

- name: Sync to CNB Repository
run: |
docker run --rm \
-v ${{ github.workspace }}:${{ github.workspace }} \
-w ${{ github.workspace }} \
-e PLUGIN_TARGET_URL="https://cnb.cool/tencent/tdesign/tdesign-api.git" \
-e PLUGIN_AUTH_TYPE="https" \
-e PLUGIN_USERNAME="cnb" \
-e PLUGIN_PASSWORD=${{ secrets.CNB_TOKEN }} \
-e PLUGIN_FORCE="true" \
tencentcom/git-sync

sync-delete-branch:
if: ${{ github.repository == 'TDesignOteam/tdesign-api' && github.event_name == 'delete' && github.event.ref_type == 'branch' }}
runs-on: ubuntu-latest
steps:
- uses: TDesignOteam//tdesign-pr-trigger-action@develop
with:
repo: 'tencent/tdesign/tdesign-api'
token: ${{ secrets.CNB_TOKEN }}
branch: ${{ github.event.ref }}
trigger: '/delete-cnb-branch'