doc_changes #483
This file contains hidden or 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
| name: 'Update docs' | |
| on: | |
| repository_dispatch: | |
| types: [doc_changes] | |
| workflow_dispatch: | |
| inputs: | |
| sha: | |
| type: string | |
| description: The SHA of the `electron/electron` commit | |
| required: true | |
| concurrency: update-docs | |
| permissions: {} | |
| jobs: | |
| update-docs: | |
| runs-on: ubuntu-latest | |
| environment: docs-updater | |
| env: | |
| SHA: ${{ github.event.client_payload.sha || github.event.inputs.sha }} | |
| steps: | |
| - name: Generate GitHub App token (updater app) | |
| uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 | |
| id: generate-token | |
| with: | |
| creds: ${{ secrets.DOCS_UPDATER_GH_APP_CREDS }} | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag: v5.0.0 | |
| with: | |
| token: ${{ steps.generate-token.outputs.token }} | |
| - uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # tag: v6.0.0 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'yarn' | |
| - name: Install dependencies | |
| run: yarn install --immutable | |
| - name: Prebuild | |
| run: | | |
| 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 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: Generate GitHub App token (approver app) | |
| uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 | |
| id: generate-token-approver | |
| with: | |
| creds: ${{ secrets.APPROVER_GH_APP_CREDS }} | |
| - name: Approve and merge pull request | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate-token-approver.outputs.token }} | |
| run: | | |
| set -eo pipefail | |
| gh pr review "docs/update-to-${SHA}" --approve | |
| sleep 30 # Checks don't always start immediately | |
| gh pr checks "docs/update-to-${SHA}" --watch --fail-fast | |
| sleep 30 # Ensure GitHub thinks the PR is mergable | |
| gh pr merge "docs/update-to-${SHA}" --squash |