Skip to content
Merged
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
74 changes: 74 additions & 0 deletions .github/workflows/sync-docs-from-cli-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Sync docs to docs site repo

on:
push:
branches:
- main
paths:
- "docs/**"
pull_request:
branches:
- main
paths:
- "docs/**"
workflow_dispatch:
Comment on lines +3 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if statement below means it only creates the PR on push and dispatch. but it'll run everything else as a test for PRs made


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@v1
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
Comment on lines +70 to +74
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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

Quick note since this is useful to have, but IIRC this step was added for collecting links of various PRs made to multiple separate repos at a time - often for sample apps.

Here we target a single source of truth and this might not be as needed, but of course no need to change it! This is a note 👾

Loading