diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 347c452..4bfda44 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -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 "actions@github.com" + - 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 "actions@github.com" 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"