Skip to content

Commit aef2ca2

Browse files
committed
feat(ci): reverse submodule sync — bump TechAPI pointer on dispatch
Add bump-techapi.yml: on a repository_dispatch (techapi-updated) from TechAPI, advance this repo's TechAPI submodule gitlink to TechAPI's latest main (payload sha, or remote HEAD fallback), commit and push to main. Idempotent no-op when already current; also runnable via workflow_dispatch. Loop-safe: the bump is pushed with GITHUB_TOKEN, whose pushes do not trigger other workflows, so notify-techapi never fires on it. Mirrors TechAPI's bump-engine.yml; needs TechAPI to add a notify-engine.yml sender (with paths-ignore on its TechEngine gitlink).
1 parent 166a017 commit aef2ca2

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

.github/workflows/bump-techapi.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: bump-techapi
2+
3+
# Reverse of notify-techapi: advance THIS repo's TechAPI submodule pointer to
4+
# TechAPI's latest main. Triggered by a repository_dispatch (`techapi-updated`)
5+
# that TechAPI's notify-engine.yml sends on a real data/site change, or run
6+
# manually. Keeps the "TechAPI @ <sha>" browsing link from going stale.
7+
#
8+
# Loop-safe by construction:
9+
# * the bump commit is pushed with the default GITHUB_TOKEN, and pushes made
10+
# by GITHUB_TOKEN do NOT trigger other workflows — so notify-techapi never
11+
# fires on it and there is no ping-pong back to TechAPI;
12+
# * TechAPI's notify-engine.yml must `paths-ignore` its own TechEngine gitlink
13+
# so it doesn't dispatch on bump-only commits (sender-side guard);
14+
# * the bump is idempotent — if the pointer already matches, it no-ops.
15+
on:
16+
repository_dispatch:
17+
types: [techapi-updated]
18+
workflow_dispatch:
19+
20+
permissions:
21+
contents: write
22+
23+
concurrency:
24+
group: bump-techapi
25+
cancel-in-progress: false
26+
27+
jobs:
28+
bump:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: main
34+
35+
- name: Bump TechAPI submodule pointer to TechAPI main
36+
env:
37+
PAYLOAD_SHA: ${{ github.event.client_payload.sha }}
38+
run: |
39+
set -euo pipefail
40+
# Prefer the sha from the dispatch payload; fall back to remote main HEAD
41+
# (covers manual runs and payload-less dispatches).
42+
SHA="${PAYLOAD_SHA:-}"
43+
if [ -z "$SHA" ]; then
44+
SHA=$(git ls-remote https://github.com/Seungpyo1007/TechAPI.git refs/heads/main | awk '{print $1}')
45+
fi
46+
if [ -z "$SHA" ]; then
47+
echo "::error::could not resolve TechAPI main sha"; exit 1
48+
fi
49+
CUR=$(git ls-tree HEAD TechAPI | awk '{print $3}')
50+
if [ "$SHA" = "$CUR" ]; then
51+
echo "TechAPI pointer already at ${SHA:0:7}; nothing to do."
52+
exit 0
53+
fi
54+
git update-index --cacheinfo "160000,${SHA},TechAPI"
55+
git config user.name "techengine-bot"
56+
git config user.email "techengine-bot@users.noreply.github.com"
57+
git commit -m "chore: bump TechAPI submodule to ${SHA:0:7}"
58+
git push origin main

0 commit comments

Comments
 (0)