Skip to content

Commit d947f9a

Browse files
ci: synchronize documentation pages on the tools.slack.dev site after changes (#423)
1 parent 9e9c4b1 commit d947f9a

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

.github/workflows/sync-docs.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Sync docs to docs site repo
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- "docs/**"
9+
workflow_dispatch:
10+
11+
jobs:
12+
config-sync:
13+
name: Sync docs to docs site repo
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Generate a GitHub token
18+
id: ghtoken
19+
uses: actions/create-github-app-token@v1
20+
with:
21+
app-id: ${{ secrets.GH_APP_ID }}
22+
owner: slackapi
23+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
24+
25+
- name: Checkout the tool repo (source)
26+
uses: actions/checkout@v4
27+
28+
- name: Checkout the docs site repo (destination)
29+
uses: actions/checkout@v4
30+
with:
31+
repository: slackapi/slackapi.github.io
32+
path: "docs_repo"
33+
token: ${{ steps.ghtoken.outputs.token }}
34+
persist-credentials: false
35+
36+
- name: Update docs in docs site repo
37+
run: |
38+
rsync -av --delete ./docs/ ./docs_repo/content/${{ github.event.repository.name }}/
39+
40+
- name: Install dependencies
41+
run: |
42+
cd docs_repo
43+
npm ci
44+
45+
- name: Build Docusaurus site
46+
run: |
47+
cd docs_repo
48+
npm run build
49+
50+
- name: Create a pull request
51+
if: ${{ github.event.pull_request.merged || github.event_name == 'workflow_dispatch' }}
52+
id: site-pr
53+
uses: peter-evans/create-pull-request@v7
54+
with:
55+
token: ${{ steps.ghtoken.outputs.token }}
56+
title: "From ${{ github.event.repository.name }}: ${{ github.event.pull_request.title || 'manual docs sync' }}"
57+
body: "${{ github.event.pull_request.body }}"
58+
author: "slackapi[bot] <186980925+slackapi[bot]@users.noreply.github.com>"
59+
committer: "slackapi[bot] <186980925+slackapi[bot]@users.noreply.github.com>"
60+
commit-message: "Sync docs from ${{ github.event.repository.name }} to docs site repo"
61+
base: "main"
62+
branch: "docs-sync-${{ github.event.repository.name }}-${{ github.sha }}"
63+
labels: docs
64+
path: "./docs_repo"
65+
66+
- name: Output the pull request link
67+
if: ${{ steps.site-pr.outputs.pull-request-url }}
68+
run: |
69+
echo "Pull request created: ${{ steps.site-pr.outputs.pull-request-url }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)