Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
embedded-react-sdk/.github/scripts/sync-snapshot.sh at main · Gusto/embedded-react-sdk · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
Gusto
embedded-react-sdk
Repository navigation
Code
Issues
Pull requests
14
(14)
Actions
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
embedded-react-sdk
/
.github
/
scripts
/
sync-snapshot.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
162 lines (144 loc) · 5.24 KB
main
Breadcrumbs
embedded-react-sdk
/
.github
/
scripts
/
sync-snapshot.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
162 lines (144 loc) · 5.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!
/usr/bin/env bash
set
-euo pipefail
#
Decides whether to create or refresh the versioned docs snapshot in the
#
downstream embedded-sdk-docs repo, then performs the file operations.
#
#
Extracted from publish-docs.yaml so the logic can be exercised locally
#
without triggering a full CI sync. In CI the workflow handles cloning,
#
wiping, copying fresh source, staging, and pushing; this script only owns
#
the snapshot decision and file operations.
#
#
Usage:
#
.github/scripts/sync-snapshot.sh --downstream <path-to-embedded-sdk-docs>
#
[--trigger workflow_run|workflow_dispatch|push]
#
[--version <x.y.z>]
#
[--dry-run]
#
#
--downstream Path to the local embedded-sdk-docs checkout. Required.
#
--trigger Simulates the GitHub Actions event name. Defaults to
#
workflow_dispatch (equivalent to a manual run: creates a
#
snapshot if missing, skips refresh).
#
--version Override the SDK version. Defaults to package.json.
#
--dry-run Print what would happen without touching any files.
#
#
Snapshot action matrix:
#
workflow_run, minor missing -> create
#
workflow_run, minor present -> refresh
#
workflow_dispatch, minor missing -> create
#
workflow_dispatch, minor present -> refresh (manual dispatch is the recovery path)
#
push -> (no-op — push path never touches snapshots)
#
#
For the create action the script copies docs/ into the downstream's docs/
#
and then runs `npx docusaurus docs:version`. Run `npm ci` in the downstream
#
docs-site/ first if node_modules is absent.
DOWNSTREAM=
"
"
TRIGGER=
"
workflow_dispatch
"
VERSION=
"
"
DRY_RUN=0
while
[[
$#
-gt
0 ]]
;
do
case
"
$1
"
in
--downstream) DOWNSTREAM=
"
$2
"
;
shift
2 ;;
--trigger) TRIGGER=
"
$2
"
;
shift
2 ;;
--version) VERSION=
"
$2
"
;
shift
2 ;;
--dry-run) DRY_RUN=1
;
shift
;;
*
)
echo
"
Unknown argument:
$1
"
>&2
;
exit
64 ;;
esac
done
if
[[
-z
"
$DOWNSTREAM
"
]]
;
then
echo
"
Error: --downstream <path> is required
"
>&2
exit
64
fi
if
[[
!
-d
"
$DOWNSTREAM
"
]]
;
then
echo
"
Error: downstream path does not exist:
$DOWNSTREAM
"
>&2
exit
1
fi
#
Resolve to the repo root of the SDK (the directory containing docs/ and package.json).
SCRIPT_DIR=
"
$(
cd
"
$(
dirname
"
${BASH_SOURCE[0]}
"
)
"
&&
pwd
)
"
SDK_ROOT=
"
$(
cd
"
${SCRIPT_DIR}
/../..
"
&&
pwd
)
"
if
[[
-z
"
$VERSION
"
]]
;
then
VERSION=
$(
node -p
"
require('
${SDK_ROOT}
/package.json').version
"
)
fi
MINOR=
$(
echo
"
$VERSION
"
|
cut -d. -f1,2
)
echo
"
SDK version :
${VERSION}
(minor
${MINOR}
)
"
echo
"
Downstream :
${DOWNSTREAM}
"
echo
"
Trigger :
${TRIGGER}
"
[[
"
$DRY_RUN
"
-eq
1 ]]
&&
echo
"
(dry run — no files will be changed)
"
echo
"
"
#
---- Decide snapshot action ----
MINOR_IN_VERSIONS=false
VERSIONS_JSON=
"
${DOWNSTREAM}
/docs-site/versions.json
"
if
[[
-f
"
$VERSIONS_JSON
"
]] \
&&
jq -e --arg key
"
${MINOR}
"
'
index($key) != null
'
"
$VERSIONS_JSON
"
>
/dev/null
2>&1
;
then
MINOR_IN_VERSIONS=true
fi
SNAPSHOT_ACTION=none
if
[[
"
$TRIGGER
"
==
"
workflow_run
"
]]
||
[[
"
$TRIGGER
"
==
"
workflow_dispatch
"
]]
;
then
if
[[
"
$MINOR_IN_VERSIONS
"
==
"
false
"
]]
;
then
SNAPSHOT_ACTION=create
else
SNAPSHOT_ACTION=refresh
fi
fi
echo
"
Snapshot action:
${SNAPSHOT_ACTION}
"
echo
"
"
if
[[
"
$SNAPSHOT_ACTION
"
==
"
none
"
]]
;
then
echo
"
Nothing to do.
"
exit
0
fi
VERSIONED_DIR=
"
${DOWNSTREAM}
/docs-site/versioned_docs/version-
${MINOR}
"
#
---- Create ----
if
[[
"
$SNAPSHOT_ACTION
"
==
"
create
"
]]
;
then
if
[[
"
$DRY_RUN
"
-eq
1 ]]
;
then
echo
"
Would copy
${SDK_ROOT}
/docs/ ->
${DOWNSTREAM}
/docs/
"
echo
"
Would run: npx docusaurus docs:version
${MINOR}
(in
${DOWNSTREAM}
/docs-site)
"
else
cp -R
"
${SDK_ROOT}
/docs/.
"
"
${DOWNSTREAM}
/docs/
"
(
cd
"
${DOWNSTREAM}
/docs-site
"
[[
!
-d
node_modules ]]
&&
npm ci
npx docusaurus docs:version
"
${MINOR}
"
)
echo
"
Created snapshot version-
${MINOR}
.
"
fi
exit
0
fi
#
---- Refresh ----
if
[[
!
-d
"
$VERSIONED_DIR
"
]]
;
then
echo
"
Error:
${MINOR}
is in versions.json but
${VERSIONED_DIR}
/ is missing.
"
>&2
exit
1
fi
updated=0
orphan=0
added=0
#
Update files already in the snapshot.
while
IFS=
read
-r snap_file
;
do
rel=
"
${snap_file
#
${VERSIONED_DIR}
/
}
"
live=
"
${SDK_ROOT}
/docs/
${rel}
"
if
[[
-f
"
$live
"
]]
;
then
[[
"
$DRY_RUN
"
-eq
0 ]]
&&
cp
"
$live
"
"
$snap_file
"
updated=
$((
updated
+
1
))
else
echo
"
orphan (no live counterpart):
${rel}
"
orphan=
$((
orphan
+
1
))
fi
done
<
<(
find
"
$VERSIONED_DIR
"
-type f
|
sort
)
#
Add files present in live docs/ but absent from the snapshot.
while
IFS=
read
-r live_file
;
do
rel=
"
${live_file
#
${SDK_ROOT}
/
docs
/
}
"
snap=
"
${VERSIONED_DIR}
/
${rel}
"
if
[[
!
-f
"
$snap
"
]]
;
then
echo
"
add (missing from snapshot):
${rel}
"
if
[[
"
$DRY_RUN
"
-eq
0 ]]
;
then
mkdir -p
"
$(
dirname
"
$snap
"
)
"
cp
"
$live_file
"
"
$snap
"
fi
added=
$((
added
+
1
))
fi
done
<
<(
find
"
${SDK_ROOT}
/docs
"
-type f
|
sort
)
echo
"
"
echo
"
Refreshed
${updated}
file(s) in version-
${MINOR}
;
${added}
added;
${orphan}
orphan(s) left as-is.
"
if
[[
"
${added}
"
-gt
0 ]]
||
[[
"
${orphan}
"
-gt
0 ]]
;
then
echo
"
"
echo
"
WARNING: structural changes detected —
${added}
file(s) added,
${orphan}
orphan(s).
"
echo
"
Verify that version-
${MINOR}
snapshot looks correct before merging.
"
fi
You can’t perform that action at this time.