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