-
Notifications
You must be signed in to change notification settings - Fork 24
ci: adds workflow for syncing docs out to docusaurus repo #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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: | ||||||||||||
|
|
||||||||||||
| 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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 👾 |
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the
ifstatement below means it only creates the PR on push and dispatch. but it'll run everything else as a test for PRs made