-
Notifications
You must be signed in to change notification settings - Fork 301
Add issue template & automation for community contributions #354
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Want to add a dev container collection? | ||
description: Dev container collection contribution template | ||
labels: [collection] | ||
|
||
title: "Add a collection to the index" | ||
|
||
body: | ||
|
||
- type: input | ||
id: name | ||
attributes: | ||
label: Collection name | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: maintainer | ||
attributes: | ||
label: Maintainer name | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: contact | ||
attributes: | ||
label: Maintainer contact link (i.e. repo issues link, email) | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: repository | ||
attributes: | ||
label: Repository URL | ||
validations: | ||
required: true | ||
|
||
- type: input | ||
id: ociReference | ||
attributes: | ||
label: OCI Reference | ||
validations: | ||
required: true | ||
|
||
- type: checkboxes | ||
attributes: | ||
label: I acknowledge that this collection provides new functionality, distinct from the existing collections part of this index | ||
options: | ||
- label: Confirm | ||
required: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Update collection | ||
on: | ||
issue_comment: | ||
types: [created] | ||
branches: | ||
- gh-pages | ||
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')) | ||
bamurtaugh marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to copilot, 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:
You can call this script from your workflow like this:
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
bamurtaugh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- name: Install js-yaml | ||
run: npm install js-yaml | ||
|
||
- run: sudo apt-get install jq | ||
|
||
- uses: stefanbuck/github-issue-praser@v3 | ||
id: issue-parser | ||
with: | ||
template-path: .github/ISSUE_TEMPLATE/update-collection.yml | ||
|
||
- run: | | ||
cat <<EOF >collection.json | ||
${{ steps.issue-parser.outputs.jsonString }} | ||
EOF | ||
|
||
- run: node _data/update-collection.js | ||
|
||
- name: Commit changes | ||
shell: bash | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" && \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll ensure PAT is available to this repo! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ? |
||
git config --global user.name "github-actions[bot]" && \ | ||
git add _data/collection-index.yml && \ | ||
git commit -m 'Add collection' && \ | ||
git push | ||
|
||
- uses: peter-evans/close-issue@v1 | ||
with: | ||
comment: Thanks so much for your contribution! Your collection is now part of our community index. Check out the <a href="https://github.com/devcontainers/devcontainers.github.io/blob/gh-pages/_data/collection-index.yml">collection-index.yml</a> and <a href="https://containers.dev/collections">containers.dev/collections</a>. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const fs = require('fs'); | ||
const yaml = require('js-yaml'); | ||
const eventPayload = require(process.env.GITHUB_EVENT_PATH); | ||
|
||
const issueBodyLines = eventPayload.issue.body.split(/\r?\n/); | ||
|
||
let name, maintainer, contact, repository, ociReference; | ||
|
||
issueBodyLines.forEach((line, index) => { | ||
const trimmedLine = line.trim().toLowerCase(); | ||
switch (trimmedLine) { | ||
case '### collection name': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 🤔 |
||
name = issueBodyLines[index + 2]; | ||
break; | ||
case '### maintainer name': | ||
maintainer = issueBodyLines[index + 2]; | ||
break; | ||
case '### maintainer contact link (i.e. repo issues link, email)': | ||
contact = issueBodyLines[index + 2]; | ||
break; | ||
case '### repository url': | ||
repository = issueBodyLines[index + 2]; | ||
break; | ||
case '### oci reference': | ||
ociReference = issueBodyLines[index + 2]; | ||
break; | ||
} | ||
}); | ||
|
||
const content = | ||
`\n- name: ${name} | ||
bamurtaugh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
maintainer: ${maintainer} | ||
contact: ${contact} | ||
repository: ${repository} | ||
ociReference: ${ociReference} | ||
`; | ||
|
||
fs.appendFileSync(`${process.env.GITHUB_WORKSPACE}/_data/collection-index.yml`, content); |
Uh oh!
There was an error while loading. Please reload this page.