gitgram/aitimemachine/beads/.github/workflows/update-vendor-hash.yml
caelum0x 49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00

108 lines
4.3 KiB
YAML

name: Update vendorHash for dependabot Go bumps
# Dependabot bumps to go.mod/go.sum invalidate the proxyVendor FOD hash in
# default.nix, which fails the nix-build CI gate. This workflow detects the
# drift, computes the new hash via scripts/update-nix-vendorhash.sh, and
# pushes the update back to the dependabot branch so the gate goes green
# without a maintainer round-trip.
#
# Tracked under beads-bz5.
#
# Why pull_request_target (not pull_request):
# GitHub gives the GITHUB_TOKEN read-only permissions on `pull_request`
# workflows triggered by dependabot, regardless of declared `permissions:`.
# `pull_request_target` runs in the trusted context of the base branch with
# full token permissions, which is required to push back to the PR branch.
#
# Safety against pull_request_target abuse:
# - The job only runs when github.actor is dependabot[bot] AND the PR head
# is on the upstream repo (head.repo.full_name == github.repository).
# Dependabot never opens PRs from forks, so this combination is not
# reachable from an external contributor.
# - We explicitly check out the PR head SHA to operate on dependabot's
# bumped go.mod/go.sum. Because dependabot is the only allowed actor and
# never modifies scripts/, the trust boundary is the dependabot bot
# itself — this is the same trust posture the project already accepts
# when merging dependabot PRs.
# - No force-push. Single commit with attribution.
#
# Caveat:
# GitHub does not retrigger pull_request workflow runs for commits
# authored by GITHUB_TOKEN. After this workflow pushes, the existing
# nix-build.yml check on this PR will remain stuck on the pre-fix commit.
# Maintainers either re-run nix-build manually, or this workflow's own
# success acts as the green signal that the hash is correct.
on:
pull_request_target:
branches: [main]
paths:
- 'go.mod'
- 'go.sum'
permissions:
contents: write
concurrency:
group: update-vendor-hash-${{ github.event.pull_request.number }}
cancel-in-progress: false
jobs:
update-vendor-hash:
name: Update default.nix vendorHash
if: >-
github.actor == 'dependabot[bot]' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout PR head
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
# pull_request_target defaults to the base ref. Explicitly check
# out the PR head so we operate on dependabot's bumped go.mod/sum.
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Nix
uses: DeterminateSystems/determinate-nix-action@f4c468f2287f0f14a113841b41f2dc8957119519 # v3
- name: Capture pre-update vendorHash
id: pre
run: |
set -euo pipefail
OLD_HASH=$(grep 'vendorHash = ' default.nix | sed 's/.*"\(.*\)".*/\1/')
echo "old_hash=$OLD_HASH" >>"$GITHUB_OUTPUT"
echo "Pre-update vendorHash: $OLD_HASH"
- name: Update vendorHash
run: ./scripts/update-nix-vendorhash.sh
- name: Detect whether hash changed
id: changed
run: |
set -euo pipefail
if git diff --quiet -- default.nix; then
echo "changed=false" >>"$GITHUB_OUTPUT"
echo "vendorHash already matched; nothing to commit."
else
echo "changed=true" >>"$GITHUB_OUTPUT"
fi
- name: Commit and push hash update
if: steps.changed.outputs.changed == 'true'
env:
# Push to the PR branch on the upstream repo. dependabot branches
# live on the same repo, so the default GITHUB_TOKEN suffices.
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add default.nix
git commit \
-m "chore(nix): update vendorHash for go.sum changes" \
-m "Auto-generated by .github/workflows/update-vendor-hash.yml in response to a dependabot Go-module bump (beads-bz5)."
git push origin "HEAD:${BRANCH}"