Skip to content

Commit 034ae57

Browse files
ci: adds workflow for syncing docs out to docusaurus repo (#29)
* docs ci: adds sync docs from cli repo workflow * fix: puts in right folder
1 parent f2a26f0 commit 034ae57

File tree

1 file changed

+74
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)