Skip to content

Commit 6ecb384

Browse files
Initial commit
0 parents  commit 6ecb384

10 files changed

+260
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @mindbuttergold/admin
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Check Community Approval
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- labeled
10+
- unlabeled
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check_approval:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Check for community approval
20+
run: |
21+
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'community-approved') }}" == "true" ]]; then
22+
echo "This PR has met the requirements for community approval."
23+
else
24+
echo "::error::This PR has not met the requirements for community approval."
25+
exit 1
26+
fi
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Check PR Thumbs Up and Manage Labels
2+
3+
on:
4+
schedule:
5+
- cron: '0 5 * * *' # Runs daily at 10:00 PM MST (5:00 AM UTC next day)
6+
- cron: '0 13 * * *' # Runs daily at 6:00 AM MST (1:00 PM UTC)
7+
- cron: '0 19 * * *' # Runs daily at 12:00 PM MST (7:00 PM UTC)
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
check-pr-thumbs-up:
14+
runs-on: ubuntu-latest
15+
env:
16+
GH_TOKEN: ${{ secrets.LABEL_PRS_TOKEN }}
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Get Open PR numbers
22+
id: get-open-prs
23+
run: |
24+
OPEN_PR_NUMS=$(gh api "/repos/${GITHUB_REPOSITORY}/pulls?state=open" -q '.[].number' | tr '\n' ' ' | sed 's/[[:space:]]*$//')
25+
26+
if [ -z "$OPEN_PR_NUMS" ]; then
27+
echo "No open PRs found."
28+
exit 0
29+
fi
30+
31+
echo "The following PR numbers are open: $OPEN_PR_NUMS"
32+
echo "OPEN_PR_NUMS=$OPEN_PR_NUMS" >> $GITHUB_ENV
33+
echo "open_prs=true" >> $GITHUB_OUTPUT
34+
35+
- name: Get PR Thumbs Up Counts and Manage Labels
36+
if: steps.get-open-prs.outputs.open_prs == 'true'
37+
run: |
38+
OPEN_PR_NUMS="${{ env.OPEN_PR_NUMS }}"
39+
eval "set -- $OPEN_PR_NUMS"
40+
41+
for PR_NUMBER in "$@"; do
42+
43+
PR_AUTHOR=$(gh api repos/${GITHUB_REPOSITORY}/pulls/$PR_NUMBER --jq '.user.login')
44+
45+
THUMBS_UP_COUNT_EXCLUDING_AUTHOR=$(gh api \
46+
-H "Accept: application/vnd.github+json" \
47+
-H "X-GitHub-Api-Version: 2022-11-28" \
48+
"/repos/${GITHUB_REPOSITORY}/issues/$PR_NUMBER/reactions" \
49+
-q "[.[] | select(.content == \"+1\" and .user.login != \"$PR_AUTHOR\")] | length")
50+
echo "PR #$PR_NUMBER has $THUMBS_UP_COUNT_EXCLUDING_AUTHOR thumbs up excluding from the author."
51+
52+
if [ "$THUMBS_UP_COUNT_EXCLUDING_AUTHOR" -ge 5 ]; then
53+
echo "Adding 'community-approved' label to PR #$PR_NUMBER."
54+
gh api -X POST \
55+
-H "Accept: application/vnd.github+json" \
56+
-H "X-GitHub-Api-Version: 2022-11-28" \
57+
"/repos/${GITHUB_REPOSITORY}/issues/$PR_NUMBER/labels" \
58+
-f "labels[]=community-approved" > /dev/null
59+
60+
else
61+
echo "PR #$PR_NUMBER does not have enough thumbs up reactions."
62+
63+
HAS_COMMUNITY_APPROVED_LABEL=$(gh api \
64+
-H "Accept: application/vnd.github+json" \
65+
-H "X-GitHub-Api-Version: 2022-11-28" \
66+
"/repos/${GITHUB_REPOSITORY}/issues/$PR_NUMBER/labels" \
67+
-q '[.[] | select(.name == "community-approved")] | length')
68+
69+
if [ "$HAS_COMMUNITY_APPROVED_LABEL" -gt 0 ]; then
70+
echo "PR #$PR_NUMBER has the 'community-approved' label."
71+
echo "Removing 'community-approved' label from PR #$PR_NUMBER."
72+
gh api -X DELETE \
73+
-H "Accept: application/vnd.github+json" \
74+
-H "X-GitHub-Api-Version: 2022-11-28" \
75+
"/repos/${GITHUB_REPOSITORY}/issues/$PR_NUMBER/labels/community-approved" > /dev/null
76+
fi
77+
fi
78+
done

.github/workflows/ossf-scorecard.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: OSSF Scorecard
2+
on:
3+
schedule:
4+
- cron: '0 5 * * 1' # Every Sunday at 10pm MST (5:00 UTC)
5+
push:
6+
branches: [ "main" ]
7+
8+
permissions: read-all
9+
10+
jobs:
11+
analysis:
12+
name: Scorecard analysis
13+
runs-on: ubuntu-latest
14+
permissions:
15+
security-events: write
16+
id-token: write
17+
18+
steps:
19+
- name: "Checkout code"
20+
uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: "Run analysis"
25+
uses: ossf/scorecard-action@v2.4.2
26+
with:
27+
results_file: results.sarif
28+
results_format: sarif
29+
repo_token: ${{ secrets.OSSF_SCORECARD_TOKEN }}
30+
publish_results: true

.github/workflows/semver-release.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Semver Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write
17+
issues: write
18+
pull-requests: write
19+
id-token: write
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "lts/*"
31+
32+
- name: Install Conventional Commits Preset Dependency
33+
run: npm i conventional-changelog-conventionalcommits@v9 -D
34+
35+
- name: Release
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: npx semantic-release@24
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: "Validate PR Title"
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- edited
8+
- reopened
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
validate_pr_title:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
pull-requests: read
18+
steps:
19+
- uses: amannn/action-semantic-pull-request@v5
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# IDE specific files
2+
.idea/
3+
.vscode/
4+
5+
# Mac
6+
.DS_Store

.releaserc.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"preset": "conventionalcommits",
3+
"plugins":
4+
[
5+
"@semantic-release/commit-analyzer",
6+
"@semantic-release/release-notes-generator",
7+
"@semantic-release/github",
8+
],
9+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 mindbuttergold
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# template-repo
2+
3+
[![CodeQL](https://github.com/mindbuttergold/template-repo/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/mindbuttergold/template-repo/actions/workflows/github-code-scanning/codeql) [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/mindbuttergold/template-repo/badge)](https://scorecard.dev/viewer/?uri=github.com/mindbuttergold/template-repo) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/10740/badge)](https://www.bestpractices.dev/projects/10740)
4+
5+
Template repo with foundational config and workflows applicable across all repository setups
6+
7+
## Included Components
8+
9+
This template repository provides the following components:
10+
- README.md
11+
- Minimal .gitignore
12+
- MIT OSS License
13+
- CODEOWNERS file
14+
- Semantic Release config file and Github Actions workflow
15+
- Automatically handles repository releases based on Conventional Commit standards
16+
- PR title validation Github Actions workflow
17+
- Ensures PR title complies with Conventional Commit standards for use with squash merging / semantic release automation
18+
- Custom PR thumbs up check Github Actions workflow
19+
- Checks all open PRs in the repo for thumbs up reactions from at least 5 community members, excluding the PR author
20+
- If 5+ thumbs up on PR, automatically adds "community-approved" label to PR
21+
- If "community-approved" label was previously added, but thumbs up reduced to below 5, it removes the label
22+
- Custom community approval label check
23+
- Checks if the "community-approved" label is present on the PR
24+
- Serves as a required check for PR mergeability
25+
26+
## Usage
27+
28+
Admin / maintainers of the mindbuttergold organization can use this template to create a new repository. The new repository will contain all of the files in this repository.
29+
30+
The only repo-specific changes that need to be made for the new repo are to this README. The badge URLs must be updated, and the openssf best practices self-certification process must be re-conducted for each repo.

0 commit comments

Comments
 (0)