Sync docs to docs site repo #9
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: Sync docs to docs site repo | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "docs/**" | |
workflow_dispatch: | |
jobs: | |
config-sync: | |
name: Sync docs to docs site repo | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate a GitHub token | |
id: ghtoken | |
uses: actions/create-github-app-token@v2 | |
with: | |
app-id: ${{ secrets.GH_APP_ID }} | |
owner: slackapi | |
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
- name: Checkout the tool repo (source) | |
uses: actions/checkout@v4 | |
- name: Checkout the docs site repo (destination) | |
uses: actions/checkout@v4 | |
with: | |
repository: slackapi/slackapi.github.io | |
path: "docs_repo" | |
token: ${{ steps.ghtoken.outputs.token }} | |
persist-credentials: false | |
- name: Update docs in docs site repo | |
run: | | |
rsync -av --delete ./docs/ ./docs_repo/content/${{ github.event.repository.name }}/ | |
- name: Install dependencies | |
run: | | |
cd docs_repo | |
npm ci | |
- name: Build Docusaurus site | |
run: | | |
cd docs_repo | |
npm run build | |
- name: Create a pull request | |
if: ${{ github.event.pull_request.merged || github.event_name == 'workflow_dispatch' }} | |
id: site-pr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ steps.ghtoken.outputs.token }} | |
title: "From ${{ github.event.repository.name }}: ${{ github.event.pull_request.title || 'manual docs sync' }}" | |
body: "${{ github.event.pull_request.body }}" | |
author: "slackapi[bot] <186980925+slackapi[bot]@users.noreply.github.com>" | |
committer: "slackapi[bot] <186980925+slackapi[bot]@users.noreply.github.com>" | |
commit-message: "Sync docs from ${{ github.event.repository.name }} to docs site repo" | |
base: "main" | |
branch: "docs-sync-${{ github.event.repository.name }}-${{ github.sha }}" | |
labels: docs | |
path: "./docs_repo" | |
- name: Output the pull request link | |
if: ${{ steps.site-pr.outputs.pull-request-url }} | |
run: | | |
echo "Pull request created: ${{ steps.site-pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY |