Discourse Topic GitHub Release Action
The discourse-topic-github-release-action is a JavaScript action that can post published GitHub releases from a repository to a Discourse instance.
We use this on our main projects to automatically post releases to Roots Discourse.
Other projects using this action:
Example usage
name: Post release topic on Discourse
on:
release:
types: [published]
jobs:
post:
runs-on: ubuntu-latest
steps:
- uses: roots/discourse-topic-github-release-action@main
with:
discourse-api-key: ${{ secrets.DISCOURSE_RELEASES_API_KEY }}
discourse-base-url: ${{ secrets.DISCOURSE_BASE_URL }}
github-token: ${{ github.token }}
discourse-category: 11
discourse-tags: |
releases
Username Mapping
The action automatically maps GitHub usernames to Discourse usernames by reading a discourse.yml file from your organization’s .github repository.
Setting up username mapping
- Create a
.github repository in your organization if it doesn’t exist
- Add a
discourse.yml file with the following format:
usernames:
github-username: discourse-username
another-user: their-discourse-name
When a release is published, the action will:
- Detect the GitHub username of the person who published the release
- Look up their username in the mapping
- Use the mapped Discourse username when creating the topic
For backward compatibility, if discourse-author-username is provided, that value is used directly. Otherwise, the action attempts username mapping (when a GitHub token is available) and falls back to system.
Setup
discourse-api-key
Required Discourse API key. Use a GitHub secret for this value.
discourse-base-url
Required Discourse base URL. Use a GitHub secret for this value.
discourse-author-username
Username for creating the topic on Discourse.
Default: system (if omitted, username mapping is attempted when a GitHub token is available)
github-token
Optional GitHub token for fetching the .github/discourse.yml file. The action uses this input first, then GITHUB_TOKEN if available.
The token must be able to read owner/.github/discourse.yml (repository contents read access). If that file cannot be read, the action falls back to system.
discourse-category
Category ID used for creating the topic on Discourse.
Tags applied to the topic when creating the topic on Discourse. Put one tag per line using a literal block scalar (|):
discourse-tags: |
releases
sage
Without the |, YAML folds the lines into a single value (releases sage), which Discourse creates as one releases-sage tag. Comma-separated values are not split either.
评论