77
88permissions :
99 contents : write
10+ issues : write # Required for creating issues on CI failure
1011
1112jobs :
1213 update-opencode-commit :
@@ -32,11 +33,59 @@ jobs:
3233 git config user.name "github-actions[bot]"
3334 git config user.email "github-actions[bot]@users.noreply.github.com"
3435
36+ # Toolchain setup for running CI checks on the updated submodule.
37+ # Steps match ci-pre-publish.yml to ensure parity with normal CI.
38+ - name : Install Linux system dependencies
39+ run : |
40+ # Required by opencode-broker (libpam-sys links against -lpam).
41+ sudo apt-get update
42+ sudo apt-get install -y libpam0g-dev
43+
44+ - name : Install Rust
45+ uses : dtolnay/rust-toolchain@stable
46+ with :
47+ components : rustfmt, clippy
48+
49+ - name : Install just
50+ uses : extractions/setup-just@v3
51+
52+ - name : Setup Node.js
53+ uses : actions/setup-node@v5
54+ with :
55+ node-version : ' 20'
56+
57+ - name : Setup Bun
58+ uses : ./.github/actions/setup-bun
59+
60+ - name : Rust cache
61+ uses : Swatinem/rust-cache@v2
62+
3563 - name : Update opencode commit
3664 id : update
3765 run : |
3866 ./scripts/update-opencode-commit.sh
3967
68+ # Validate the updated submodule before committing.
69+ # Auto-fix formatting first, then run the full CI check suite.
70+ # If checks fail, the workflow fails and the broken commit is never pushed.
71+ - name : Auto-format and run CI checks
72+ id : ci_checks
73+ if : steps.update.outputs.needs_update == 'true'
74+ run : |
75+ set -euo pipefail
76+
77+ # Auto-fix formatting issues introduced by the submodule update
78+ just fmt || true
79+
80+ # If formatting produced changes, stage and commit them
81+ if ! git diff --quiet; then
82+ git add -A
83+ git commit -m "style: auto-format after opencode submodule update" || true
84+ fi
85+
86+ # Run the full CI check suite
87+ just ci-checks
88+
4089 - name : Verify OCI description label
4190 id : verify_oci
4291 run : python3 scripts/extract-oci-description.py packages/core/src/docker/Dockerfile
69118 if : always()
70119 env :
71120 UPDATE_OUTCOME : ${{ steps.update.outcome }}
121+ CI_CHECKS_OUTCOME : ${{ steps.ci_checks.outcome }}
72122 VERIFY_OCI_OUTCOME : ${{ steps.verify_oci.outcome }}
73123 COMMIT_PUSH_OUTCOME : ${{ steps.commit_push.outcome }}
74124 SUBMODULE_BRANCH : ${{ steps.update.outputs.submodule_branch }}
@@ -117,7 +167,7 @@ jobs:
117167 fi
118168
119169 status_line="ℹ️ No update needed"
120- if [[ "${UPDATE_OUTCOME:-}" == "failure" || "${VERIFY_OCI_OUTCOME:-}" == "failure" || "${COMMIT_PUSH_OUTCOME:-}" == "failure" || "${UPDATE_OUTCOME:-}" == "cancelled" || "${VERIFY_OCI_OUTCOME:-}" == "cancelled" || "${COMMIT_PUSH_OUTCOME:-}" == "cancelled" ]]; then
170+ if [[ "${UPDATE_OUTCOME:-}" == "failure" || "${CI_CHECKS_OUTCOME:-}" == "failure" || "${ VERIFY_OCI_OUTCOME:-}" == "failure" || "${COMMIT_PUSH_OUTCOME:-}" == "failure" || "${UPDATE_OUTCOME:-}" == "cancelled" || "${CI_CHECKS_OUTCOME :-}" == "cancelled" || "${VERIFY_OCI_OUTCOME:-}" == "cancelled" || "${COMMIT_PUSH_OUTCOME:-}" == "cancelled" ]]; then
121171 status_line="❌ Failed"
122172 elif [[ "${PUSHED:-}" == "true" ]]; then
123173 status_line="✅ Updated and pushed"
@@ -156,6 +206,47 @@ jobs:
156206 echo ""
157207 echo "**Step outcomes:**"
158208 echo "- update: \`${UPDATE_OUTCOME:-n/a}\`"
209+ echo "- ci_checks: \`${CI_CHECKS_OUTCOME:-n/a}\`"
159210 echo "- verify_oci: \`${VERIFY_OCI_OUTCOME:-n/a}\`"
160211 echo "- commit_push: \`${COMMIT_PUSH_OUTCOME:-n/a}\`"
161212 } >> "${GITHUB_STEP_SUMMARY}"
213+
214+ - name : Create issue on CI failure
215+ if : failure() && steps.ci_checks.outcome == 'failure'
216+ env :
217+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
218+ LATEST_COMMIT : ${{ steps.update.outputs.latest_commit }}
219+ SUBMODULE_REPO_URL : ${{ steps.update.outputs.submodule_repo_url }}
220+ SUBMODULE_BRANCH : ${{ steps.update.outputs.submodule_branch }}
221+ run : |
222+ set -euo pipefail
223+ run_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
224+ commit_short="${LATEST_COMMIT:0:12}"
225+ commit_url="${SUBMODULE_REPO_URL:-}/commit/${LATEST_COMMIT:-unknown}"
226+ branch="${SUBMODULE_BRANCH:-dev}"
227+
228+ body="## Automated submodule update failed CI checks
229+
230+ The [update-opencode-commit workflow](${run_url}) attempted to update the
231+ opencode submodule to [\`${commit_short}\`](${commit_url}) from the
232+ \`${branch}\` branch, but \`just ci-checks\` failed after auto-formatting.
233+
234+ ### What to do
235+
236+ 1. Check the [workflow run logs](${run_url}) for the specific failure
237+ 2. Common causes:
238+ - **TypeScript typecheck failure** in a fork-* package — fix in the opencode fork and push to \`dev\`
239+ - **Rust clippy/build failure** in opencode-broker — fix in the fork
240+ - **Formatting issue** that \`just fmt\` couldn't resolve — manual fix needed
241+ 3. After fixing, the next scheduled run (every 2 hours) will retry automatically
242+
243+ ### Context
244+
245+ - Submodule commit: [\`${commit_short}\`](${commit_url})
246+ - Fork branch: \`${branch}\`
247+ - Workflow run: [${GITHUB_RUN_ID}](${run_url})"
248+
249+ gh issue create \
250+ --title "CI checks failed for opencode submodule update (${commit_short})" \
251+ --label "bug,automated" \
252+ --body "${body}"
0 commit comments