This repository provides a GitHub Action to post a string or the contents of a given file to a specific Discourse topic.
We use it as part of our API documentation management suite: Rapidoc as a Discourse theme component to render OpenAPI specifications in forum posts. We upload specifications using this action, create changelogs with that one, snippets with this one, and finally upload the changelogs with the action from this repository.
discourse_url
- your discourse instance domain, e.g. "community.developer.gridx.dediscourse_topic_id
- the ID of the Discourse post to reply to. You can find the ID, e.g., by inspecting your post in the browser and looking fordata-topic-id="<n>"
in thearticle
element. (XPath//h1/@data-topic-id
)discourse_api_key
- your discourse API key. It needstopics:write
permissions.discourse_user
- the discourse user on whose behalf the action should be executed.github_sha
- the commit hash to put into the post as reference, can be obtained using$GITHUB_SHA
when running in an action or withgit rev-parse --short HEAD
content_file
- the (text) file containing the contents to be posted, relative to the repositories root. Use either this orcontent
directly.content
- the contents to be posted. Use either this orcontent_file
to load the content from a file. D'uh.
- Create a topic for your changelogs. This action will be configured to post the changelog as a reply to this topic.
- Get the required parameters as described above
- Configure the action in your GH workflow, preferably on release
- name: Test Action against gridX community example post
uses: ./
with:
discourse_url: ${{secrets.DISCOURSE_URL}}
discourse_topic_id: <n>
discourse_api_key: ${{secrets.DISCOURSE_API_KEY}}
discourse_user: ${{secrets.DISCOURSE_USER}}
github_sha: ${{env.SHORT_SHA}}
content_file: ./changelog.md
# OR content: "content as string"
- You can run the action locally using
npm run test:run
, providing the configuration parameters through the environment. See test.ts. - See package.json for linting, testing and formatting scripts.