-
Notifications
You must be signed in to change notification settings - Fork 91
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
Action to automatically create hack day discussion threads #801
Comments
@mfisher87 Hey Matt, I would like to take this up. But before that I wanted to ask you what level of proficiency would be required in github actions for handling this one. I have none as of now (😂) but is it something that can be handled with little knowledge of actions? |
@Sherwin-14, before taking on anything else, would you mind either finishing the outstanding work on #792 or request that somebody else finishes it? |
When you're ready, I think this is a reasonable first GitHub Action workflow for a learner :) It needs two pieces: A "cron" trigger, which uses the Linux cron syntax to define how frequently the workflow repeats; and a step which posts to our GitHub discussions something like this. |
I am working on that one it's taking a bit longer than I expected because of writing those unittests. |
@mfisher87 Hey Matt, |
That looks like a good choice! Thanks for doing the research on this :) |
Well.. That didn't work out very well 😅, looks like the action I mentioned is broken. I resorted to using github CLI's graphQL API. I also had problems getting the text from previous hackdays embedded correctly, so I wrote my own. Here's how the workflow file looks: name: Generate Discussion Thread for Hackdays
on:
workflow_dispatch:
jobs:
create-discussion-threads:
runs-on: ubuntu-latest
permissions:
discussions: write
contents: read
steps:
- name: Generate the Hackathon title
run: |
DATE=$(date --iso-8601 | sed 's|-|/|g')
echo "DISCUSSION_TITLE=Hackathon $DATE" >> $GITHUB_ENV
- name: Set the Hackathon description
run: |
echo "DISCUSSION_BODY=Reporting out on earthaccess hack days. Use the 'comment' button at the very bottom to send a message. Additionally, consider sending issues and PRs relevant to your work to help make the job of future readers easier. It is okay to duplicate information here! Use the reply feature to have a discussion under any comment. Enjoy!" >> $GITHUB_ENV
- name: Create Discussions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY_ID: \"R_kgDOL9OsOA\"
CATEGORY_ID: \"DIC_kwDOL9OsOM4ClttG\"
run: |
gh api graphql -f query="
mutation
{createDiscussion
(
input:
{
repositoryId: ${{ env.REPOSITORY_ID }},
categoryId: ${{ env.CATEGORY_ID }},
body: \"${{ env.DISCUSSION_BODY }}\",
title: \"${{ env.DISCUSSION_TITLE }}\"
}
)
{
discussion {id}
}
}" Thoughts? |
I think it looks great! Nice work! What do you think of moving the literal quotes from the I like that it's set up with workflow dispatch instead of cron, as there will be weeks (like the past holiday weeks) where we skip the hackathon. |
Alright, Nice! On another note, the repo id and category id i am using are from my fork, Could you provide me the repo and category id for main repo. I had used giscus for getting the id's. |
Looks like repository ID is Strange that the repository ID I'm getting back is significantly different in length than the one you used in your test. I tested a few repositories and it looks like the structure of the ID has changed over time. I used the GitHub CLI to query the GraphQL API: $ gh api graphql -f query='
{
repository(owner: "nsidc", name: "earthaccess") {
id
name
discussionCategories(first: 10) {
nodes {
id
name
}
}
}
}' {
"data": {
"repository": {
"id": "MDEwOlJlcG9zaXRvcnkzOTk4Njc1Mjk=",
"name": "earthaccess",
"discussionCategories": {
"nodes": [
{
"id": "DIC_kwDOF9V-ic4B_awC",
"name": "Announcements"
},
{
"id": "DIC_kwDOF9V-ic4B_awD",
"name": "General"
},
{
"id": "DIC_kwDOF9V-ic4CdYaN",
"name": "Hack days"
},
{
"id": "DIC_kwDOF9V-ic4B_awF",
"name": "Ideas"
},
{
"id": "DIC_kwDOF9V-ic4CNngd",
"name": "Polls"
},
{
"id": "DIC_kwDOF9V-ic4B_awE",
"name": "Q\u0026A"
},
{
"id": "DIC_kwDOF9V-ic4B_awG",
"name": "Show and tell"
}
]
}
}
}
} |
Awesome work on this, thank you @Sherwin-14 ❤️ |
We're currently making these manually:
#800
We should be able to set up their creation on a bi-weekly cron in GitHub Actions!
The text was updated successfully, but these errors were encountered: