-
Notifications
You must be signed in to change notification settings - Fork 0
ci: configure sync-docs-dispatcher in main CI workflow #219
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| <!-- header:start --> | ||
|
|
||
| # GitHub Reusable Workflow: Sync Documentation Dispatcher | ||
|
|
||
| <div align="center"> | ||
| <img src="../logo.svg" width="60px" align="center" alt="Sync Documentation Dispatcher" /> | ||
| </div> | ||
|
|
||
| --- | ||
|
|
||
| <!-- header:end --> | ||
|
|
||
| <!-- badges:start --> | ||
|
|
||
| [](https://github.com/hoverkraft-tech/ci-github-publish/releases) | ||
| [](http://choosealicense.com/licenses/mit/) | ||
| [](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-publish?style=social) | ||
| [](https://github.com/hoverkraft-tech/ci-github-publish/blob/main/CONTRIBUTING.md) | ||
|
|
||
| <!-- badges:end --> | ||
|
|
||
| <!-- | ||
| // jscpd:ignore-start | ||
| --> | ||
|
|
||
| <!-- overview:start --> | ||
|
|
||
| ## Overview | ||
|
|
||
| Reusable workflow: Sync documentation to public-docs repository | ||
|
|
||
| Purpose: | ||
|
|
||
| - Download the uploaded documentation artifact | ||
| - Generate a GitHub App token with appropriate permissions | ||
| - Dispatch a repository event to hoverkraft-tech/public-docs | ||
| - Pass artifact information to the receiver workflow | ||
|
|
||
| Prerequisites: | ||
|
|
||
| - GitHub App with `repo` and artifact access permissions configured | ||
| - Documentation artifact uploaded by prepare-docs action | ||
|
|
||
| ### Permissions | ||
|
|
||
| - **`contents`**: `read` | ||
|
|
||
| <!-- overview:end --> | ||
|
|
||
| <!-- usage:start --> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```yaml | ||
| name: Sync Documentation Dispatcher | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| permissions: | ||
| contents: read | ||
| jobs: | ||
| sync-docs-dispatcher: | ||
| uses: hoverkraft-tech/ci-github-publish/.github/workflows/sync-docs-dispatcher.yml@b2a6d08d60e0adff6736caf6fdaa5fd3bcdd473a # 0.13.0 | ||
| secrets: | ||
| # GitHub App private key to generate GitHub token in place of github-token. | ||
| # See https://github.com/actions/create-github-app-token. | ||
| github-app-key: "" | ||
| with: | ||
| # GitHub App ID to generate GitHub token in place of github-token. | ||
| # See https://github.com/actions/create-github-app-token. | ||
| github-app-id: "" | ||
|
|
||
| # ID of the uploaded documentation artifact. | ||
| # | ||
| # This input is required. | ||
| artifact-id: "" | ||
| ``` | ||
|
|
||
| <!-- usage:end --> | ||
|
|
||
| <!-- inputs:start --> | ||
|
|
||
| ## Inputs | ||
|
|
||
| ### Workflow Call Inputs | ||
|
|
||
| | **Input** | **Description** | **Required** | **Type** | **Default** | | ||
| | ------------------- | ---------------------------------------------------------------- | ------------ | ---------- | ----------- | | ||
| | **`github-app-id`** | GitHub App ID to generate GitHub token in place of github-token. | **false** | **string** | - | | ||
| | | See <https://github.com/actions/create-github-app-token>. | | | | | ||
| | **`artifact-id`** | ID of the uploaded documentation artifact. | **true** | **string** | - | | ||
|
|
||
| <!-- inputs:end --> | ||
|
|
||
| <!-- secrets:start --> | ||
|
|
||
| ## Secrets | ||
|
|
||
| | **Secret** | **Description** | **Required** | | ||
| | -------------------- | ------------------------------------------------------------------------- | ------------ | | ||
| | **`github-app-key`** | GitHub App private key to generate GitHub token in place of github-token. | **false** | | ||
| | | See <https://github.com/actions/create-github-app-token>. | | | ||
|
|
||
| <!-- secrets:end --> | ||
|
|
||
| <!-- outputs:start --> | ||
| <!-- outputs:end --> | ||
|
|
||
| <!-- examples:start --> | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Complete Integration | ||
|
|
||
| ```yaml | ||
| name: Main CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| ci: | ||
| name: Run CI | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Run tests | ||
| run: npm test | ||
|
|
||
| prepare-docs: | ||
| name: Prepare Documentation | ||
| needs: ci | ||
| if: github.event_name != 'schedule' && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| artifact-id: ${{ steps.prepare-docs.outputs.artifact-id }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Prepare documentation | ||
| id: prepare-docs | ||
| uses: hoverkraft-tech/public-docs/.github/actions/prepare-docs@18facec04f2945f4d66d510e8a06568497b73c54 # 0.1.0 | ||
| with: | ||
| paths: | | ||
| README.md | ||
| docs/**/*.md | ||
| .github/workflows/*.md | ||
|
|
||
| sync-docs: | ||
| name: Sync Documentation | ||
| needs: prepare-docs | ||
| permissions: | ||
| contents: read | ||
| uses: hoverkraft-tech/ci-github-publish/.github/workflows/sync-docs-dispatcher.yml@b2a6d08d60e0adff6736caf6fdaa5fd3bcdd473a # 0.13.0 | ||
| with: | ||
| github-app-id: ${{ vars.PUBLIC_DOCS_APP_ID }} | ||
| artifact-id: ${{ needs.prepare-docs.outputs.artifact-id }} | ||
| secrets: | ||
| github-app-key: ${{ secrets.PUBLIC_DOCS_APP_PRIVATE_KEY }} | ||
| ``` | ||
|
|
||
| <!-- examples:end --> | ||
|
|
||
| <!-- contributing:start --> | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-publish/blob/main/CONTRIBUTING.md) for more details. | ||
|
|
||
| <!-- contributing:end --> | ||
|
|
||
| <!-- security:start --> | ||
| <!-- security:end --> | ||
|
|
||
| <!-- license:start --> | ||
|
|
||
| ## License | ||
|
|
||
| This project is licensed under the MIT License. | ||
|
|
||
| SPDX-License-Identifier: MIT | ||
|
|
||
| Copyright © 2025 hoverkraft-tech | ||
|
|
||
| For more details, see the [license](http://choosealicense.com/licenses/mit/). | ||
|
|
||
| <!-- license:end --> | ||
|
|
||
| <!-- generated:start --> | ||
|
|
||
| --- | ||
|
|
||
| This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor). | ||
|
|
||
| <!-- generated:end --> | ||
|
|
||
| <!-- | ||
| // jscpd:ignore-end | ||
| --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # Reusable workflow: Sync documentation to public-docs repository | ||
| # | ||
| # Purpose: | ||
| # | ||
| # - Download the uploaded documentation artifact | ||
| # - Generate a GitHub App token with appropriate permissions | ||
| # - Dispatch a repository event to hoverkraft-tech/public-docs | ||
| # - Pass artifact information to the receiver workflow | ||
| # | ||
| # Prerequisites: | ||
| # | ||
| # - GitHub App with `repo` and artifact access permissions configured | ||
| # - Documentation artifact uploaded by prepare-docs action | ||
|
|
||
| name: Sync Documentation Dispatcher | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| github-app-id: | ||
| description: | | ||
| GitHub App ID to generate GitHub token in place of github-token. | ||
| See https://github.com/actions/create-github-app-token. | ||
| required: false | ||
| type: string | ||
| artifact-id: | ||
| description: | | ||
| ID of the uploaded documentation artifact. | ||
| required: true | ||
| type: string | ||
| secrets: | ||
| github-app-key: | ||
| description: | | ||
| GitHub App private key to generate GitHub token in place of github-token. | ||
| See https://github.com/actions/create-github-app-token. | ||
| required: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| sync-docs: | ||
| name: Dispatch Documentation Sync | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # jscpd:ignore-start | ||
|
|
||
| - uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 | ||
| if: inputs.github-app-id | ||
| id: generate-token | ||
| with: | ||
| app-id: ${{ inputs.github-app-id }} | ||
| private-key: ${{ secrets.github-app-key }} | ||
| owner: hoverkraft-tech | ||
| repositories: public-docs | ||
|
|
||
| # jscpd:ignore-end | ||
|
|
||
| - id: dispatch | ||
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | ||
| env: | ||
| ARTIFACT_ID: ${{ inputs.artifact-id }} | ||
| SOURCE_REPO: ${{ github.repository }} | ||
| SOURCE_RUN_ID: ${{ github.run_id }} | ||
| SOURCE_SHA: ${{ github.sha }} | ||
| with: | ||
| github-token: ${{ steps.generate-token.outputs.token || github.token }} | ||
| script: | | ||
| const artifactId = process.env.ARTIFACT_ID; | ||
| const sourceRepo = process.env.SOURCE_REPO; | ||
| const sourceRunId = process.env.SOURCE_RUN_ID; | ||
| const sourceSha = process.env.SOURCE_SHA; | ||
|
|
||
| if (!artifactId) { | ||
| return core.setFailed('artifact-id is required'); | ||
| } | ||
|
|
||
| core.info('Dispatching documentation sync event...'); | ||
|
|
||
| await github.rest.repos.createDispatchEvent({ | ||
| owner: 'hoverkraft-tech', | ||
| repo: 'public-docs', | ||
| event_type: 'sync-docs', | ||
| client_payload: { | ||
| artifact_id: artifactId, | ||
| source_repo: sourceRepo, | ||
| source_run_id: sourceRunId, | ||
| source_sha: sourceSha, | ||
| } | ||
| }); | ||
|
|
||
| core.summary.addHeading('Documentation Dispatch Summary', 2); | ||
| core.summary.addTable([ | ||
| [{data: 'Property', header: true}, {data: 'Value', header: true}], | ||
| ['Artifact ID', artifactId], | ||
| ['Source Repository', sourceRepo], | ||
| ['Run ID', sourceRunId], | ||
| ['Commit SHA', sourceSha], | ||
| ]); | ||
| await core.summary.write(); | ||
|
|
||
| core.info('✅ Documentation sync event dispatched successfully'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
revert those changes
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.
Reverted README.md changes. Commit: 8072cdf