Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add workflow to publish release notes directly to discourse#7860

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@ricardoV94
Copy link
Member

@ricardoV94ricardoV94 commentedJul 21, 2025
edited by github-actionsbot
Loading

twiecki reacted with rocket emoji
DISCOURSE_URL: "https://discourse.pymc.io"
DISCOURSE_CATEGORY: "Development"
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_BODY: ${{ github.event.release.body }}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not sure if I need to escape to json or not

Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds automation to publish GitHub release notes directly to a Discourse forum. The implementation includes a Python script that fetches release information from GitHub and posts it as a formatted topic to Discourse using their API.

Key changes:

  • Python script for publishing release notes to Discourse with error handling and content formatting
  • GitHub Actions workflow triggered on release publication
  • Configuration updates to allow print statements in the script

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

FileDescription
scripts/publish_release_notes_to_discourse.pyMain script that handles Discourse API communication and content formatting
.github/workflows/publish-release-notes-to-discourse.ymlGitHub Actions workflow to trigger the script on release events
pyproject.tomlLinting configuration update to allow print statements in the new script

url = f"{config['DISCOURSE_URL']}/posts.json"

try:
response = requests.post(url, headers=headers, data=topic_data)

Choose a reason for hiding this comment

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

The request should use 'json=topic_data' instead of 'data=topic_data' since the headers specify 'Content-Type: application/json' but this parameter sends form-encoded data.

Suggested change
response=requests.post(url,headers=headers,data=topic_data)
response=requests.post(url,headers=headers,json=topic_data)

Copilot uses AI. Check for mistakes.
Copy link
MemberAuthor

@ricardoV94ricardoV94Jul 21, 2025
edited
Loading

Choose a reason for hiding this comment

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

data seemed to work fine, but this is something I'm still not sure about, also on how to pass from the workflow to script. Rather test and see how it goes

Comment on lines 100 to 108
headers = {"Api-Key": config["DISCOURSE_API_KEY"], "Api-Username": config["DISCOURSE_USERNAME"]}
url = f"{config['DISCOURSE_URL']}/posts.json"

try:
response = requests.post(url, headers=headers, data=topic_data)

Choose a reason for hiding this comment

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

The headers for the POST request are missing 'Content-Type: application/json' which is included in the GET request headers and is necessary when sending JSON data.

Suggested change
headers= {"Api-Key":config["DISCOURSE_API_KEY"],"Api-Username":config["DISCOURSE_USERNAME"]}
url=f"{config['DISCOURSE_URL']}/posts.json"
try:
response=requests.post(url,headers=headers,data=topic_data)
headers= {
"Api-Key":config["DISCOURSE_API_KEY"],
"Api-Username":config["DISCOURSE_USERNAME"],
"Content-Type":"application/json",
}
url=f"{config['DISCOURSE_URL']}/posts.json"
try:
response=requests.post(url,headers=headers,json=topic_data)

Copilot uses AI. Check for mistakes.
@ricardoV94ricardoV94force-pushed thepublish-release-notes-to-discourse branch from31727a9 tod56efbeCompareJuly 21, 2025 12:22
Comment on lines +8 to +34
publish-to-discourse:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install dependencies
run: pip install requests

- name: Publish release to Discourse
env:
DISCOURSE_API_KEY: ${{ secrets.DISCOURSE_API_KEY }}
DISCOURSE_USERNAME: "pymc-bot"
DISCOURSE_URL: "https://discourse.pymc.io"
DISCOURSE_CATEGORY: "Development"
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_BODY: ${{ github.event.release.body }}
RELEASE_URL: ${{ github.event.release.html_url }}
REPO_NAME: ${{ github.repository }}

Check warning

Code scanning / zizmor

overly broad permissions Warning

overly broad permissions
@ricardoV94
Copy link
MemberAuthor

ricardoV94 commentedJul 22, 2025
edited
Loading

I suggest we merge and the next release will confirm whether the release.body output is formatting correctly or not, that's my only doubt, and I don't know a way to test locally. I've tested locally the rest.

@ricardoV94ricardoV94 merged commit5f611b5 intopymc-devs:mainJul 22, 2025
13 checks passed
@maresb
Copy link
Contributor

I'm a bit late to the review party, but ideally we should scopesecrets.DISCOURSE_API_KEY to therelease environment. This would dramatically reduce the attack surface for a GitHub actor to steal the API key.

It's really simple and low-effort:

  • Remove the API key from "repository secrets"
  • Readd the key to "environment secrets" under the "release" environment
  • Add the "release" environment to thispublish-to-discourse job, copying the line from the above link into this workflow.

I don't have admin permissions on the PyMC repo to set this up myself.

@ricardoV94
Copy link
MemberAuthor

Ok I'll try it

maresb reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@twieckitwieckitwiecki approved these changes

@maresbmaresbAwaiting requested review from maresb

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@ricardoV94@maresb@twiecki

[8]ページ先頭

©2009-2025 Movatter.jp