Skip to content
Closed
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
114 changes: 106 additions & 8 deletions .github/workflows/opencode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,124 @@ on:

jobs:
opencode:
if: |
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
if: >
(
github.event_name == 'issue_comment' &&
github.event.comment.body != '' &&
(
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
)
) ||
(
github.event_name == 'pull_request_review_comment' &&
github.event.comment.body != '' &&
(
contains(github.event.comment.body, ' /oc') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
startsWith(github.event.comment.body, '/opencode')
)
)
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: read
contents: write
pull-requests: write
issues: read

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false

# 1️⃣ 自动确定源分支(不再支持 branch=xxx)
- name: Determine source branch
id: src
run: |
if [ "${{ github.event.issue.pull_request.url }}" != "" ]; then
echo "source_branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT
else
echo "source_branch=${{ github.event.repository.default_branch }}" >> $GITHUB_OUTPUT
fi

- name: Checkout source branch
uses: actions/checkout@v6
with:
ref: ${{ steps.src.outputs.source_branch }}
persist-credentials: false

- name: Record source branch
id: src_branch
run: |
echo "source_branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT

- name: Run opencode
uses: anomalyco/opencode/github@latest
env:
DEEPSEEK_API_KEY: ${{ secrets.DEEPSEEK_API_KEY }}
with:
model: deepseek/deepseek-reasoner
model: deepseek/deepseek-reasoner

- name: Detect opencode branch
id: oc_branch
run: |
echo "oc_branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT

- name: Find PR created by opencode
id: find_pr
run: |
BRANCH="${{ steps.oc_branch.outputs.oc_branch }}"
PR=$(gh pr list \
--head "$BRANCH" \
--state open \
--json number \
--jq '.[0].number')
echo "pr_number=$PR" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Fix PR base
if: >
steps.find_pr.outputs.pr_number != '' &&
!startsWith(steps.src_branch.outputs.source_branch, 'opencode/')
run: |
gh pr edit ${{ steps.find_pr.outputs.pr_number }} \
--base "${{ steps.src_branch.outputs.source_branch }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Fast-forward merge new opencode branch into previous opencode branch
if: >
steps.find_pr.outputs.pr_number != '' &&
startsWith(steps.src_branch.outputs.source_branch, 'opencode/')
run: |
NEW_PR=${{ steps.find_pr.outputs.pr_number }}
NEW_BRANCH=${{ steps.oc_branch.outputs.oc_branch }}
OLD_BRANCH=${{ steps.src_branch.outputs.source_branch }}

OLD_PR="${{ github.event.issue.number }}"
if [ -z "$OLD_PR" ]; then
OLD_PR="${{ github.event.pull_request.number }}"
fi

git fetch origin "$OLD_BRANCH" "$NEW_BRANCH"
git checkout "$OLD_BRANCH"

if git merge --ff-only "origin/$NEW_BRANCH"; then
git push origin "$OLD_BRANCH"
else
exit 0
fi

BODY=$(gh pr view "$NEW_PR" --json body --jq .body)
if [ -n "$BODY" ]; then
gh pr comment "$OLD_PR" --body "$BODY"
fi

gh pr close "$NEW_PR" --delete-branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions no-entity-lag/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@//rule:datapack.bzl", "complete_datapack_config", "minecraft_versions_range")

pack_version = "1.0.0"

complete_datapack_config(
game_versions = minecraft_versions_range("1.20.2"),
modrinth_project_id = "HydPXwHs",
pack_id = "no_entity_lag",
pack_version = pack_version,
deps = [
"README.md",
"pack.png",
"//:license_gpl",
"//datapack-function-library:dfl",
],
)
Empty file added no-entity-lag/NEWS.md
Empty file.