Skip to content

GitHub Integration is not pushing changes in PRs #1417

Closed

Description

@MarcelBochtler

In my private repository a PR was opened by the renovate bot, updating a dependency.
This resulted in a test failure, and I described in a comment how I wanted this to be fixed and used /oc fix this.

The opencode.yml workflow was triggered, and according to the logs it fixed the issue, and created a commit:

{"command":"cd /home/runner/work/my-project/my-project && git commit -m \"...\"","description":"Commit the changes"}

Then opencode created the summary and posted this as a comment in the PR.

Unfortunately, the commit was never pushed to the PR branch and seems to be lost.

My configuration:

name: opencode

on:
  issue_comment:
    types: [created]

jobs:
  opencode:
    if: |
      contains(github.event.comment.body, '/oc') ||
      contains(github.event.comment.body, '/opencode')
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Run opencode
        uses: sst/opencode/github@latest
        env:
          OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
        with:
          model: openrouter/qwen/qwen3-coder:free

The used opencode version was 0.3.84

Activity

  1. fwang commented on Aug 22, 2025

    @fwang
    Contributor

    hmm that's weird... does this happen everytime?

  2. AKTheKnight commented on Nov 4, 2025

    @AKTheKnight
    Contributor

    Think I've hit this too, couldn't find this issue (Thanks bot for telling me): #3893

    As far as I can tell it's because the branchIsDirty() check is false because git status --porcelain returns nothing if we've committed the changes, even if they haven't been pushed

    Image
  3. code-yeongyu commented on Feb 7, 2026

    @code-yeongyu
    Contributor

    Root Cause Analysis

    The bug has been identified. There are two separate implementations of branchIsDirty():

    1. github/index.ts (Used by GitHub Action) — BUGGY ❌

    // Line 751-755
    async function branchIsDirty() {
      console.log("Checking if branch is dirty...")
      const ret = await $`git status --porcelain`
      return ret.stdout.toString().trim().length > 0
    }

    This only checks for uncommitted changes via git status --porcelain. If the AI agent already committed the changes (via git commit), git status --porcelain returns empty — so this function returns false, and the push is skipped.

    2. packages/opencode/src/cli/cmd/github.ts (Used by CLI opencode github) — FIXED ✅

    // Line 1112-1127
    async function branchIsDirty(originalHead: string) {
      console.log("Checking if branch is dirty...")
      const ret = await $`git status --porcelain`
      const status = ret.stdout.toString().trim()
      if (status.length > 0) {
        return { dirty: true, uncommittedChanges: true }
      }
      const head = await $`git rev-parse HEAD`
      return {
        dirty: head.stdout.toString().trim() !== originalHead,
        uncommittedChanges: false,
      }
    }

    This correctly captures originalHead before AI work, then compares HEAD after — detecting both uncommitted changes AND new commits.

    The Fix

    The github/index.ts implementation needs to be updated to match the CLI version:

    1. Capture originalHead = git rev-parse HEAD before calling chat()
    2. In branchIsDirty(), check both git status --porcelain AND HEAD !== originalHead
    3. Pass uncommittedChanges flag to push functions so they know whether to git add . && git commit first

    As @AKTheKnight correctly identified in #3893, the branchIsDirty() check is false because git status --porcelain returns nothing after committed changes.

    The fix already exists in the CLI version (packages/opencode/src/cli/cmd/github.ts), it just needs to be ported to the GitHub Action version (github/index.ts).

  4. github-actions commented on Apr 9, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions