From e3050e5cb170b854800e8b67982d0017c9dc9018 Mon Sep 17 00:00:00 2001 From: samson910022 Date: Tue, 8 Sep 2026 23:33:16 +0800 Subject: [PATCH 1/2] feat(ci): add PR checks for unit-test, shellcheck and docker build --- .github/workflows/ci.yml | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..8e58ac3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,64 @@ +name: CI +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + unit-test: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 + with: + node-version: 20 + cache: npm + - run: npm ci + - run: npm test -- --runInBand + + shellcheck: + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - name: bash syntax check + run: | + bash -n entrypoint.sh + bash -n tests/test-integration.sh + bash -n tests/test-streaming-real.sh + - name: Run ShellCheck + run: | + if ! command -v shellcheck >/dev/null; then + sudo apt-get update && sudo apt-get install -y shellcheck + fi + shellcheck -S warning entrypoint.sh tests/test-integration.sh tests/test-streaming-real.sh + + docker-build: + runs-on: ubuntu-latest + timeout-minutes: 15 + permissions: + contents: read + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 + - uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5 + with: + context: . + file: ./Dockerfile + push: false + cache-from: type=gha + cache-to: type=gha,mode=max From 83a115f37478b3d548b4a4a9610b63fae054dd58 Mon Sep 17 00:00:00 2001 From: samson910022 Date: Tue, 8 Sep 2026 23:38:47 +0800 Subject: [PATCH 2/2] fix(ci): skip docker publish on forks (upstream namespace guard) --- .github/workflows/docker-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index a651c9b..8491a7d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -12,6 +12,8 @@ env: jobs: build-and-push: + # Forks share this file but must not push to the upstream image namespace. + if: github.repository == 'TiaraBasori/OpenCode2API' runs-on: ubuntu-latest permissions: contents: read