Skip to content

Commit 7bc9623

Browse files
chore: updated tutorial workflow so it makes a PR instead of pushing to main
1 parent 6e2a41f commit 7bc9623

2 files changed

Lines changed: 34 additions & 20 deletions

File tree

.github/scripts/process-passport-tutorials.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ TUTORIALS_DIR="${PASSPORT_ROOT}/_tutorials~"
1212

1313
echo "Processing Passport tutorials..."
1414

15-
# Load features.json to get feature groups
1615
FEATURES_JSON="${PASSPORT_ROOT}/features.json"
1716
if [ ! -f "${FEATURES_JSON}" ]; then
1817
echo "Error: features.json not found at ${FEATURES_JSON}"
1918
exit 1
2019
fi
2120

22-
# Create _tutorials directory in docs repo
23-
DOCS_TUTORIALS_DIR="${DOCS_REPO_DIR}/docs/main/example/zkEVM/unity/passport-examples/_tutorials"
24-
mkdir -p "${DOCS_TUTORIALS_DIR}"
21+
# Base directory for usage guides in the docs repo
22+
DOCS_USAGE_GUIDES_DIR="${DOCS_REPO_DIR}/docs/main/build/unity/usage-guides"
2523

2624
# Check if _tutorials~ directory exists
2725
if [ ! -d "${TUTORIALS_DIR}" ]; then
@@ -40,12 +38,16 @@ else
4038
if [ -f "${TUTORIAL_FILE}" ]; then
4139
echo "Found tutorial for ${GROUP_NAME}"
4240

41+
# Define the destination directory for this feature group
42+
DEST_GROUP_DIR="${DOCS_USAGE_GUIDES_DIR}/${GROUP_NAME}"
43+
mkdir -p "${DEST_GROUP_DIR}"
44+
4345
# Use the folder name directly for the destination filename
4446
OUTPUT_FILENAME="${GROUP_NAME}.md"
4547

46-
# Copy the tutorial file
47-
cp "${TUTORIAL_FILE}" "${DOCS_TUTORIALS_DIR}/${OUTPUT_FILENAME}"
48-
echo "Copied ${TUTORIAL_FILE} to ${DOCS_TUTORIALS_DIR}/${OUTPUT_FILENAME}"
48+
# Copy the tutorial file to its new group directory
49+
cp "${TUTORIAL_FILE}" "${DEST_GROUP_DIR}/${OUTPUT_FILENAME}"
50+
echo "Copied ${TUTORIAL_FILE} to ${DEST_GROUP_DIR}/${OUTPUT_FILENAME}"
4951
else
5052
echo "Warning: No tutorial.md found for feature group ${GROUP_NAME}"
5153
fi

.github/workflows/publish-passport-tutorials.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
repository: immutable/docs
3838
token: ${{ secrets.UNITY_SDK_DOCS_WORKFLOW }}
3939
path: imx-docs
40-
ref: 'main'
40+
ref: 'DVR-295-docs-restructure'
4141

4242
- name: Setup environment variables
4343
run: echo "CLONE_DIR=./imx-docs" >> $GITHUB_ENV
@@ -65,20 +65,32 @@ jobs:
6565
.github/scripts/process-passport-tutorials.sh
6666
shell: bash
6767

68-
- name: Commit and Push Changes to Docs Repo
68+
- name: Create Pull Request in Docs Repo
69+
id: create_pr
6970
run: |
7071
cd "$CLONE_DIR"
71-
if git status --porcelain | grep -q .; then
72-
git add .
73-
74-
# Commit with reference to source commit
75-
COMMIT_MSG="docs: Update Passport tutorials from Unity SDK (Ref: ${GITHUB_SHA::8})"
76-
git commit -m "$COMMIT_MSG"
77-
78-
# Push to the target branch
79-
git push -u origin main
80-
echo "Successfully pushed Passport tutorial changes to docs repo"
81-
else
72+
if ! git status --porcelain | grep -q .; then
8273
echo "No changes to commit"
74+
echo "pr_url=" >> $GITHUB_OUTPUT
75+
exit 0
8376
fi
77+
78+
BRANCH_NAME="chore/sdk-docs-update-${{ github.run_id }}"
79+
git checkout -b $BRANCH_NAME
80+
81+
git add .
82+
git commit -m "Update example app tutorials from SDK repo"
83+
git push -u origin $BRANCH_NAME
84+
echo "Successfully pushed changes to docs repo on branch $BRANCH_NAME"
85+
86+
PR_URL=$(gh pr create \
87+
--title "Update example app tutorials from SDK repo" \
88+
--body "Automated PR from unity-immutable-sdk to update tutorials. Review and merge if all looks good." \
89+
--base DVR-295-docs-restructure \
90+
--repo immutable/docs)
91+
92+
echo "Successfully created PR in docs repo: $PR_URL"
93+
echo "pr_url=${PR_URL}" >> $GITHUB_OUTPUT
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.UNITY_SDK_DOCS_WORKFLOW }}
8496
shell: bash

0 commit comments

Comments
 (0)