Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/upstream-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ jobs:

- name: Pull the API spec and the screen catalog
id: sync
env:
# The API repo is private; the default GITHUB_TOKEN can't read it.
GH_TOKEN: ${{ secrets.SYNC_TOKEN }}
run: |
if [ -z "$GH_TOKEN" ]; then
echo "::error::SYNC_TOKEN is not set. Add a fine-grained token with Contents: read on CompositeCode/substratalapps.com (and Contents + Pull requests: write on this repo)."
exit 1
fi
api=$(scripts/sync-openapi.sh)
ruby scripts/import-screens.rb https://specs.substratalapps.com/spec/
echo "api=$api" >> "$GITHUB_OUTPUT"
Expand Down
7 changes: 6 additions & 1 deletion scripts/sync-openapi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# SOURCE is a path or URL to openapi.yaml. Default: the API repo's main branch,
# which is what production runs (main deploys on merge). Writes
# Packages/SubstratalKit/Sources/SubstratalAPI/openapi.yaml.
# The API repo is private: set GH_TOKEN (or GITHUB_TOKEN) to a token that can
# read it, or curl gets a 404.
# Prints the spec's info.version. Exits 0 with "unchanged" when nothing moved,
# so the scheduled workflow can decide whether to open a pull request.
set -euo pipefail
Expand All @@ -19,7 +21,10 @@ APP_COPY="$ROOT/Packages/SubstratalKit/Sources/SubstratalAPI/openapi.yaml"
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT
if [[ "$SOURCE" =~ ^https?:// ]]; then
curl -fsSL "$SOURCE" -o "$tmp"
token="${GH_TOKEN:-${GITHUB_TOKEN:-}}"
auth=()
[[ -n "$token" && "$SOURCE" == https://raw.githubusercontent.com/* ]] && auth=(-H "Authorization: Bearer $token")
curl -fsSL "${auth[@]+"${auth[@]}"}" "$SOURCE" -o "$tmp"
else
cp "$SOURCE" "$tmp"
fi
Expand Down
Loading