-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kartikay <[email protected]>
- Loading branch information
1 parent
a953fa1
commit 9ca2aa9
Showing
1 changed file
with
22 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,44 +30,36 @@ jobs: | |
- name: "Generate Documentation" | ||
run: "mage gen:docs" | ||
|
||
- name: "Clone docs repository" | ||
run: | | ||
git clone --depth 1 --branch $DOCS_BRANCH https://${{ secrets.GITHUB_TOKEN }}@github.com/$DOCS_REPO.git docs-repo || { | ||
echo "Failed to clone docs repository" | ||
exit 1 | ||
} | ||
- name: "Configure Git" | ||
run: | | ||
cd docs-repo | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
- name: "Checkout docs repository" | ||
uses: "actions/checkout@v4" | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
repository: "${{ env.DOCS_REPO }}" | ||
path: "docs-repo" | ||
ref: "main" | ||
|
||
- name: "Sync documentation changes" | ||
id: "sync" | ||
run: | | ||
mkdir -p $(dirname $GENERATED_DOCS_FILE) | ||
mkdir -p docs-repo/$(dirname $TARGET_DOCS_FILE) | ||
touch docs-repo/$TARGET_DOCS_FILE | ||
rsync -avz $GENERATED_DOCS_FILE docs-repo/$TARGET_DOCS_FILE | ||
cp -v $GENERATED_DOCS_FILE docs-repo/$TARGET_DOCS_FILE | ||
cd docs-repo | ||
git config user.name "GitHub Actions" | ||
git config user.email "[email protected]" | ||
git add $TARGET_DOCS_FILE | ||
if ! git diff --cached --exit-code; then | ||
echo "Changes detected in $TARGET_DOCS_FILE." | ||
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV | ||
git checkout -b 'update-generated-docs' | ||
git commit -m "Update generated docs" | ||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$DOCS_REPO | ||
git push origin update-generated-docs | ||
# Store the token in a file that can be accessed by the CLI | ||
echo "${{ secrets.GITHUB_TOKEN }}" > token.txt | ||
gh auth login --with-token < token.txt | ||
gh pr create \ | ||
--body "" \ | ||
--title "docs: update zed docs" \ | ||
--head "update-generated-docs" \ | ||
--base "main" | ||
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV | ||
else | ||
echo "No changes detected in $TARGET_DOCS_FILE." | ||
echo "No changes detected" | ||
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV | ||
fi | ||
- name: "Create pull request" | ||
if: | | ||
env.CHANGES_DETECTED == 'true' | ||
uses: "peter-evans/create-pull-request@v7" | ||
with: | ||
token: "${{ secrets.GITHUB_TOKEN }}" | ||
path: "docs-repo" | ||
title: "Auto-generated PR: Update zed docs" | ||
body: "This PR was auto-generated by GitHub Actions." | ||
branch: "auto-update-branch" |