forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (94 loc) · 3.96 KB
/
Copy pathsync-docs.yml
File metadata and controls
110 lines (94 loc) · 3.96 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
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
name: Sync Mintlify Docs back to Github
on:
push:
branches:
- main
paths:
- "docs/**.mdx"
workflow_dispatch:
jobs:
sync-docs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Convert .mdx files to README.md
run: |
declare -A FILE_MAP=(
["docs/doc/developer/sdk/python.mdx"]="sdks/python/README.md"
["docs/doc/developer/sdk/ReactNative.mdx"]="sdks/react-native/README.md"
["docs/doc/developer/sdk/swift.mdx"]="sdks/swift/README.md"
["docs/doc/hardware/omiGlass.mdx"]="omiGlass/README.md"
)
for MDX_FILE in "${!FILE_MAP[@]}"; do
README_FILE="${FILE_MAP[$MDX_FILE]}"
# Create directory if it doesn't exist
mkdir -p "$(dirname "$README_FILE")"
if [ -f "$MDX_FILE" ]; then
echo "Processing: $MDX_FILE → $README_FILE"
awk 'BEGIN{printing=0} /^---$/ {printing=!printing; next} printing==0 {print}' "$MDX_FILE" | tail -n +2 > temp.md
path_depth=$(awk -F'/' '{print NF-1}' <<< "$README_FILE")
image_base_path=""
for ((i=0; i<$path_depth; i++)); do
image_base_path+="../"
done
sed -i "s|](/images/|](${image_base_path}docs/images/|g" temp.md
echo "<!-- This file is auto-generated from $MDX_FILE. Do not edit manually. -->" | cat - temp.md > "$README_FILE"
rm temp.md
echo "Successfully generated $README_FILE"
else
echo "Warning: File $MDX_FILE not found, skipping..."
ls -la "$(dirname "$MDX_FILE")"
fi
done
- name: Debug file existence
run: |
echo "Checking for generated README files:"
for dir in sdks/*/; do
if [ -f "${dir}README.md" ]; then
echo "✅ ${dir}README.md exists"
else
echo "❌ ${dir}README.md does not exist"
fi
done
# A GITHUB_TOKEN-authored PR does not trigger pull_request workflows, so it
# would arrive with zero checks run. Mint the Omi Bot token first and pass
# it to create-pull-request so the generated diff is verified by the same
# lanes as any human PR.
- name: Generate Omi Bot token
id: app-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.OMI_BOT_APP_ID }}
private-key: ${{ secrets.OMI_BOT_PRIVATE_KEY }}
permission-contents: write
permission-pull-requests: write
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: "chore: sync docs to README files"
title: "chore: sync docs to README files"
body: |
This PR was automatically created by the Sync Docs workflow.
branch: sync-docs
base: main
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
# The PR was authored with the Omi Bot app token so the generated diff is
# verified by the same lanes as any human PR. Enable auto-merge (no
# --admin) so the merge waits for those checks to pass and branch
# protection to be satisfied, then let it complete on its own.
- name: Enable auto-merge on the sync PR
if: steps.create_pr.outputs.pull-request-operation == 'created'
run: |
gh pr merge --auto --merge --delete-branch "$PR_URL"
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
PR_URL: ${{ steps.create_pr.outputs.pull-request-url }}