From ecd4f5421be58e24aef0b3ad1ece1f937b39d646 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 16 Sep 2025 18:11:14 -0700 Subject: [PATCH 1/2] ci: change automated docs update to use PRs --- .github/CODEOWNERS | 4 ++++ .github/workflows/update-docs.yml | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 710c2bf48..7d77db6e3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,2 +1,6 @@ * @electron/wg-ecosystem /blog/ @electron/wg-outreach + +# There is no code owner for the docs directory +# so that bots can approve automated PRs to it +/docs/ diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index e0f2c6fd1..c68816456 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -18,6 +18,10 @@ jobs: update-docs: runs-on: ubuntu-latest environment: docs-updater + env: + SHA: ${{ github.event.client_payload.sha || github.event.inputs.sha }} + permissions: + pull-requests: write steps: - name: Generate GitHub App token uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 @@ -35,14 +39,33 @@ jobs: run: yarn install --frozen-lockfile - name: Prebuild run: | - yarn pre-build ${{ github.event.client_payload.sha || github.event.inputs.sha }} + yarn pre-build ${SHA} git add . if [ "$(git status --porcelain | grep -v 'docs/latest/.sha')" = "" ]; then echo "Unexpectedly found no new content for docs - this is probably a bug" exit 1 fi - - name: Push changes + - name: Push changes to branch uses: dsanders11/github-app-commit-action@43de6da2f4d927e997c0784c7a0b61bd19ad6aac # v1.5.0 with: message: 'chore: update ref to docs (🤖)' + ref: 'docs/update-to-${{ env.SHA }}' token: ${{ steps.generate-token.outputs.token }} + - name: Create pull request + shell: bash + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} + run: | + gh pr create \ + --title "chore: update ref to docs (🤖)" \ + --body "Automated PR to update the docs to the latest commit (${SHA})" \ + --head "docs/update-to-${SHA}" \ + --base main + - name: Approve and merge pull request + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + PR_NUMBER=$(gh pr list --head "docs/update-to-${SHA}" --json number --jq '.[0].number') + gh pr review ${PR_NUMBER} --approve + gh pr merge ${PR_NUMBER} --auto --squash From d56b4e19c578c43370b75b352ebac9313934cb5a Mon Sep 17 00:00:00 2001 From: David Sanders Date: Tue, 16 Sep 2025 22:42:37 -0700 Subject: [PATCH 2/2] ci: use branch name directly for `gh pr` commands --- .github/workflows/update-docs.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index c68816456..dc02c91c8 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -66,6 +66,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - PR_NUMBER=$(gh pr list --head "docs/update-to-${SHA}" --json number --jq '.[0].number') - gh pr review ${PR_NUMBER} --approve - gh pr merge ${PR_NUMBER} --auto --squash + gh pr review "docs/update-to-${SHA}" --approve + gh pr merge "docs/update-to-${SHA}" --auto --squash