Skip to content

Commit

Permalink
fixed workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Kartikay <[email protected]>
  • Loading branch information
kartikaysaxena committed Feb 7, 2025
1 parent 41264b1 commit a953fa1
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ env:
permissions:
contents: "write"
pull-requests: "write"
actions: "write"
repository-projects: "write"

jobs:
sync-docs:
Expand All @@ -30,48 +32,42 @@ jobs:

- name: "Clone docs repository"
run: |
git clone --depth 1 --branch $DOCS_BRANCH https://github.com/$DOCS_REPO.git docs-repo || {
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: "Sync documentation changes"
id: "sync"
run: |
rsync -r --delete $GENERATED_DOCS_FILE/ docs-repo/$TARGET_DOCS_FILE
cd docs-repo
if ! git diff --exit-code; then
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
else
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
fi
- name: "Configure Git"
if: |
env.CHANGES_DETECTED == 'true'
run: |
cd docs-repo
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: "Commit and push changes"
if: |
env.CHANGES_DETECTED == 'true'
- 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
cd docs-repo
git add $TARGET_DOCS_FILE
git commit -m "Update generated docs"
git push origin $DOCS_BRANCH
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
- name: "Create pull request"
if: |
env.CHANGES_DETECTED == 'true'
uses: "peter-evans/create-pull-request@v5"
with:
token: "${{ secrets.GITHUB_TOKEN }}"
commit-message: "Update generated docs"
branch: "update-generated-docs"
title: "Sync generated docs"
body: |
Update zed documentation in directory `$TARGET_DOCS_FILE` with the latest version from the zed repository
base: "$DOCS_BRANCH"
# 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"
else
echo "No changes detected in $TARGET_DOCS_FILE."
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
fi

0 comments on commit a953fa1

Please sign in to comment.