Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 13 additions & 49 deletions .github/workflows/sync-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Sync docs to docs site repo
name: Sync tools docs to site repo

on:
push:
branches:
- main
paths:
- "docs/**"
pull_request:
branches:
- main
Expand All @@ -9,10 +14,9 @@ on:
workflow_dispatch:

jobs:
config-sync:
name: Sync docs to docs site repo
runs-on: ubuntu-latest

get-token:
runs-on: ubuntu-latest
steps:
- name: Generate a GitHub token
id: ghtoken
Expand All @@ -22,48 +26,8 @@ jobs:
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
call-sync-from-tools-docs-workflow:
needs: get-token
uses: slackapi/another-repo/.github/workflows/sync-from-tools-docs.yml@main
secrets:
token: ${{ needs.get-token.outputs.token }}