Skip to content

Commit

Permalink
switch to peter-evans
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 a953fa1 commit d403ce1
Showing 1 changed file with 22 additions and 30 deletions.
52 changes: 22 additions & 30 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit d403ce1

Please sign in to comment.