Skip to content
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

Add issue template & automation for community contributions #354

Closed
wants to merge 2 commits into from

Conversation

bamurtaugh
Copy link
Member

@bamurtaugh bamurtaugh commented Feb 17, 2024

Fixes #244

As part of devcontainers/spec#405, @samruddhikhandale had the excellent suggestion to incorporate #244, which involves both issue templates + automation for adding content from issues into code.

In this case, I've added:

  • An issue template update-collection.yml to help contributors more easily provide the info we require as part of community contributions
  • A GitHub Actions workflow for checking for a comment #sign-off from a spec maintainer
  • Once a maintainer signs off, the issue is parsed, and its collection is added to collection-index.yml
  • The issue is then closed, thanking the user for their contribution and linking them to the community index to check out the update!

You can try this out in my fork:

  • Create an issue with the new template (quick access link here)
  • Comment #sign-off (this needs to be done by a member of the maintainers GH team)
  • Observe as the issue is soon closed and the index is updated!

Here's an example issue where I completed this flow. The code change performed by the GitHub Action is here.

@samruddhikhandale I'd love to get your review on this - does the flow work well for you? Any edge cases I might not have accounted for? Does the wording throughout (in the template, in the comment automatically added after, etc) make sense?

@samruddhikhandale
Copy link
Member

samruddhikhandale commented Feb 21, 2024

@bamurtaugh I tried testing on your fork, and created two issues. However, it did not create a PR for me 😕
Looks like https://github.com/bamurtaugh/devcontainers.github.io-fork/actions/workflows/collection.yml wasn't triggered.

Oops, I didn't add sign-off comment. However, this time it skipped the job run. See https://github.com/bamurtaugh/devcontainers.github.io-fork/actions/runs/7995173889/job/21834893149

Looks like https://github.com/bamurtaugh/devcontainers.github.io-fork/blob/gh-pages/.github/workflows/collection.yml#L10 needs to be tweaked in your fork.

@bamurtaugh
Copy link
Member Author

So strange it skipped the job run! I just tried adding your username explicitly to the collection.yml to see if that'd help: https://github.com/bamurtaugh/devcontainers.github.io-fork/blob/gh-pages/.github/workflows/collection.yml.

@bamurtaugh
Copy link
Member Author

Looks like https://github.com/bamurtaugh/devcontainers.github.io-fork/blob/gh-pages/.github/workflows/collection.yml#L10 needs to be tweaked in your fork.

Yeah, I agree. Could you see if commenting #sign-off works now, since I added your username explicitly? Wondering if the check for being part of the maintainers team doesn't work well.

Copy link
Member

@samruddhikhandale samruddhikhandale left a comment

Choose a reason for hiding this comment

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

This is super cool and will be super helpful for the community!
Thank you so much for contributing this 👏

_data/update-collection.js Show resolved Hide resolved
.github/workflows/collection.yml Show resolved Hide resolved
.github/workflows/collection.yml Show resolved Hide resolved
jobs:
update_collection:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '#sign-off') && (github.event.comment.user.login == 'bamurtaugh' || contains(github.event.comment.user.login, 'devcontainers/maintainers'))
Copy link
Member

Choose a reason for hiding this comment

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

According to copilot, contains(github.event.comment.user.login, 'devcontainers/maintainers')) might not work. See 👇

No, the syntax you've provided is incorrect for a GitHub Actions workflow.

If you want to check if the user who commented is a member of the 'devcontainers/maintainers' team, you can't do it directly in the workflow file. GitHub Actions does not provide a direct way to check team membership.

However, you can create a script that uses the GitHub API to check if a user is a member of a specific team, and then call that script from your workflow.

Here is a simple example of how you might do this using a bash script and the GitHub CLI:

#!/bin/bash
user="$1"
team="devcontainers/maintainers"

if gh team view "$team" --json members | jq -e --arg user "$user" '.members[] | select(.login == $user)'; then
  echo "$user is a member of $team"
  exit 0
else
  echo "$user is not a member of $team"
  exit 1
fi

You can call this script from your workflow like this:

- name: Check if user is a team member
  run: ./check_team_membership.sh ${{ github.event.comment.user.login }}
  env:
    GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Copy link
Member

Choose a reason for hiding this comment

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

Committing directly to a repo is not allowed, every commit needs a corresponding PR. Even though we use BOT's PAT, it won't have those privileges.

@bamurtaugh How about we remove the #sign-off bit, and once someone opens a new issue with the new Template, we open a PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

As an update: I'm actively trying to switch this over to a PR workflow in my fork (you can see progress here). Since I'm not deeply experienced with creating GH Actions, I'm trying to get a lot of help from Copilot 😄 so I'm not sure how close I am or not to getting this working (been running into a whole bunch of different errors).

.github/workflows/collection.yml Show resolved Hide resolved
- name: Commit changes
shell: bash
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com" && \
Copy link
Member

Choose a reason for hiding this comment

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

This might not work due to our org polcies. Can you add something similar to https://github.com/devcontainers/images/blob/main/.github/workflows/version-history.yml#L89-L121 instead?

Copy link
Member

Choose a reason for hiding this comment

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

I'll ensure PAT is available to this repo!

- name: Commit changes
shell: bash
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com" && \
Copy link
Member

Choose a reason for hiding this comment

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

💡 Instead of "Github-actions", how about we use credentials of https://github.com/devcontainers-bot ?

issueBodyLines.forEach((line, index) => {
const trimmedLine = line.trim().toLowerCase();
switch (trimmedLine) {
case '### collection name':
Copy link
Member

Choose a reason for hiding this comment

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

If someone edits the issue and accidentally manipulates it, then this action would fail 🤔
As a maintainer, could be hard to remember this. Maybe add a note to the issue template?

@bamurtaugh
Copy link
Member Author

Closing in favor of #382!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using Issue Forms for collections-index.yml?
2 participants