Skip to content

Commit

Permalink
Merge pull request #90 from JMielbrecht/jmielbrecht-dynamic-pr-template
Browse files Browse the repository at this point in the history
Create Dynamic Template Based on PR Content
  • Loading branch information
Firgrep authored Oct 31, 2024
2 parents a1fb1df + d4a1792 commit 0a4ca7d
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 97 deletions.
172 changes: 75 additions & 97 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,98 +1,76 @@
<!-- Thank you for wanting to contribute to sPhil! 🧙 🦉 -->
<!-- We would like to keep our code and writing as neat and tidy as possible, and would appreciate if you could verify the following checklist if you are submitting philosophical or literary content -->

## PR Author's Note

<!-- Write your PR text here -->

## Checklist

- [ ] Philosophical or literary contribution (docs). Leave **unchecked** for
<code>code</code> contribution.

- **IMPLIED CONSENT** By opening this pull request and contributing
philosophical or literary content, I accept that my writing is submitted
under the
[ATTRIBUTION-NONCOMMERCIAL-SHAREALIKE 4.0 INTERNATIONAL](https://creativecommons.org/licenses/by-nc-sa/4.0/),
which:

- Prohibits commercial reuse of the content.
- Allows sharing, remixing, and building upon the material as long as
attribution is given.

I understand that my writing may be modified, remixed, and built upon by
others within the `systemphil/sphil` or sPhil project, in accordance
with the license terms, indefinitely. See
[legal code](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode.en).

- **REQUIRED** I have followed the
[formatting guidelines](https://github.com/systemphil/sphil/blob/dev/src/pages/contributing/formatting/basic-markdown.md)
and verified there are no formatting bugs.
[Try markdown preview here](https://markdownlivepreview.com/).
- **REQUIRED** I have followed the
[Chicago author-date style](https://www.chicagomanualofstyle.org/tools_citationguide/citation-guide-2.html).
- **REQUIRED** I have added or verified metadata title, description, and
contributors at the _very top_ of the file followed by a `##` title
heading. Additionally, I have ensured `isArticle` is set to `true`.
Example:

```md
---
title: The Immediate Difference Between Pure Being and Pure Nothing
description:
Learn about the difference between being and nothing in Hegel's
Science of Logic.
isArticle: true
authors: Jerry Maguire (2024)
editors: Steve Stevenson (2023), Karen Hansen (2022)
contributors:
---

## My Article Title
```

<details>

<summary>Further information</summary>

I have signed the document with my name/username under either as
`Authors`, `Editors` or `Contributors`.

> Use **Authors** if you have created and substantially added content.
> Use **Editor** if you have made substantial edits or review.
> Use **Contributor** if you have made minor edits, reviews or
> contributions.
> If you've done multiple, pick the most weighted: Author > Editor >
> Contributor.
> If you prefer to remain anonymous, that's fine too, but note that a
> record of your contributions based on your GitHub username will exist
> here in the codebase.

</details>

- **REQUIRED** I have ensured that the
[project's central bibliography](https://github.com/systemphil/sphil/blob/main/README_BIBLIOGRAPHY.md)
contains the necessary bibliographical details for the citations I have
used.

- _Optional_ My article is a stub or I want to actively encourage
contribution, I've added the Stub component to the bottom of my content
or where relevant:

```ts
import Stub from "@/components/Stub";

<Stub />;
```

- **If Docs contribution is unchecked:** Code contribution
([Apache version 2 license](https://www.apache.org/licenses/LICENSE-2.0.txt))
<details>

All code apart of what is inside `src/pages/**` (excluding
`/contributing/**`, `_app.mdx`, `_document.tsx`, `_meta.json`,
`acknowledgements.mdx`, `index.mdx`, `privacy.mdx`, `team.mdx`, `terms.mdx`)
is subject to Apache version 2 license. Basically, anything outside of
content, literature, philosophy.

</details>

## Author's Note

<!-- Briefly describe your changes and their purpose -->

<details>
<summary>📝 Guidelines for Philosophical/Literary Contributions</summary>

### License Agreement

By submitting this PR, you agree to license your content under the
[CC BY-NC-SA 4.0 License](https://creativecommons.org/licenses/by-nc-sa/4.0/).

### Required Steps

1. Follow the
[formatting guidelines](https://github.com/systemphil/sphil/blob/dev/src/pages/contributing/formatting/basic-markdown.md)
2. Use
[Chicago author-date style](https://www.chicagomanualofstyle.org/tools_citationguide/citation-guide-2.html)
for citations
3. Update the
[project's central bibliography](https://github.com/systemphil/sphil/blob/main/README_BIBLIOGRAPHY.md)
4. Add metadata at the top of your file:

```md
---
title: Your Title Here
description: Brief description of your content
isArticle: true
authors: Your Name (Year)
editors: Editor Name (Year)
contributors: Contributor Name (Year)
---

## Your Article Title
```

### Optional

Consider adding the Stub component to encourage further contributions.

</details>

<details>
<summary>💻 Guidelines for Code Contributions</summary>

### Required Steps

1. Ensure code adheres to project coding standards
2. Thoroughly test all changes

### License Scope

The Apache License 2.0 applies to all code except content within `src/pages/**`
(with specific exclusions like `/contributing/**`, `_app.mdx`, `_document.tsx`,
etc.). This primarily covers technical implementations rather than content,
literature, or philosophy.

</details>

<details>
<summary>ℹ️ Additional Information</summary>

- Philosophical/literary content: Licensed under CC BY-NC-SA 4.0
- Code contributions: Licensed under Apache License 2.0
- Please sign your contribution in the metadata under Authors, Editors, or
Contributors
</details>

## License Agreement

By submitting this PR, you agree to license your content under the
[CC BY-NC-SA 4.0 License](https://creativecommons.org/licenses/by-nc-sa/4.0/)
and your code under the
[Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt).
75 changes: 75 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: PR Labeler
on: [pull_request]

permissions:
contents: read
pull-requests: write
issues: write

jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_LABELING_CREDENTIALS }}
script: |
const fs = require('fs');
const path = require('path');
function getFileExtensions(files) {
return files.map(file => path.extname(file).toLowerCase()).filter(ext => ext !== '');
}
async function addLabels(extensions) {
let labels = [];
let hasContentChanges = false;
let hasCodeChanges = false;
extensions.forEach(ext => {
if (ext === '.mdx') {
hasContentChanges = true;
} else {
hasCodeChanges = true;
}
})
if (hasContentChanges) {
labels.push('CONTENT');
}
if (hasCodeChanges) {
labels.push('CODE');
}
// Get current labels
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const currentLabelNames = currentLabels.map(label => label.name);
// cross-reference current PR labels with the up-to-date label list
if (labels.length > 0 && labels.some(label => !currentLabelNames.includes(label))) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
}
}

const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});

const changedFiles = files.map(f => f.filename);
const extensions = getFileExtensions(changedFiles);
await addLabels(extensions);

0 comments on commit 0a4ca7d

Please sign in to comment.