diff --git a/tier0/hooks/post_gen_project.py b/tier0/hooks/post_gen_project.py index 22e521a..4b8f82f 100644 --- a/tier0/hooks/post_gen_project.py +++ b/tier0/hooks/post_gen_project.py @@ -30,8 +30,8 @@ def addTopic(): ] subprocess.call(gh_cli_command) -if CREATE_REPO: +if CREATE_REPO == "True": createGithubRepo() -if RECEIVE_UPDATES: - addTopic() \ No newline at end of file +if RECEIVE_UPDATES == "True": + addTopic() diff --git a/tier1/hooks/post_gen_project.py b/tier1/hooks/post_gen_project.py index f75d2ef..2acbd25 100644 --- a/tier1/hooks/post_gen_project.py +++ b/tier1/hooks/post_gen_project.py @@ -30,8 +30,8 @@ def addTopic(): ] subprocess.call(gh_cli_command) -if CREATE_REPO: +if CREATE_REPO == "True": createGithubRepo() -if RECEIVE_UPDATES: +if RECEIVE_UPDATES == "True": addTopic() diff --git a/tier2/cookiecutter.json b/tier2/cookiecutter.json index d392afd..b159a65 100644 --- a/tier2/cookiecutter.json +++ b/tier2/cookiecutter.json @@ -4,6 +4,7 @@ "project_org": "DSACMS", "project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", "project_description": "This is the project description, could match github.com repo description.", + "code_owners": "Git usernames of code owners; separated by commas.", "project_visibility": ["public", "internal", "private"], "create_repo": [true, false], "receive_updates": [true, false], diff --git a/tier2/hooks/post_gen_project.py b/tier2/hooks/post_gen_project.py index 09dd2f2..4b8f82f 100644 --- a/tier2/hooks/post_gen_project.py +++ b/tier2/hooks/post_gen_project.py @@ -30,8 +30,8 @@ def addTopic(): ] subprocess.call(gh_cli_command) -if CREATE_REPO: +if CREATE_REPO == "True": createGithubRepo() -if RECEIVE_UPDATES: +if RECEIVE_UPDATES == "True": addTopic() diff --git a/tier2/{{cookiecutter.project_slug}}/.github/workflows/checks.yml b/tier2/{{cookiecutter.project_slug}}/.github/workflows/checks.yml index 836be09..320417a 100644 --- a/tier2/{{cookiecutter.project_slug}}/.github/workflows/checks.yml +++ b/tier2/{{cookiecutter.project_slug}}/.github/workflows/checks.yml @@ -15,7 +15,9 @@ jobs: needs: resolve-repolinter-json runs-on: ubuntu-latest env: - RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json}} + {% raw %} + RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json }} + {% endraw %} steps: - uses: actions/checkout@v4 - run: echo $RAW_JSON > repolinter.json diff --git a/tier2/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml b/tier2/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml new file mode 100644 index 0000000..5e889b7 --- /dev/null +++ b/tier2/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml @@ -0,0 +1,62 @@ +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + update-contributors: + runs-on: ubuntu-latest + name: Update contributors info in MAINTAINERS.md + permissions: + contents: write + pull-requests: write + steps: + # Update contributor list + - name: Contribute List + uses: akhilmhdh/contributors-readme-action@v2.3.10 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # https://github.com/marketplace/actions/contribute-list#optional-parameters + readme_path: MAINTAINERS.md + use_username: false + commit_message: "BOT: Update contributors info in MAINTAINERS.md" + + # Update contributor count + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pull changes from contributors-readme-action + run: | + git pull + + - name: Get repository contributors count + id: get_contributors + # https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors + # https://docs.github.com/en/graphql/reference/objects#repositorycollaboratorconnection + # https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#communicating-with-graphql + # CANNOT have newlines! + run: | + OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) + REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) + QUERY='query { repository(owner: \"'"$OWNER"'\", name: \"'"$REPO"'\") { collaborators { totalCount } } }' + CONTRIBUTORS=$(curl -s -X POST -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "{\"query\": \"$QUERY\"}" https://api.github.com/graphql | jq -r '.data.repository.collaborators.totalCount') + echo "Total contributors: $CONTRIBUTORS" + echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT + + - name: Replace slug in MAINTAINERS.md with number of contributors + # https://stackoverflow.com/questions/10613643/replace-a-unknown-string-between-two-known-strings-with-sed + run: | + CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }} + sed -i 's/.*/ '"$CONTRIBUTORS"' /g' MAINTAINERS.md + + - name: Commit and push changes + # https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 + # commit changes, but if no changes exist, then exit cleanly + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git add MAINTAINERS.md + git commit -m "BOT: Update contributors info in MAINTAINERS.md" || exit 0 + git push diff --git a/tier2/{{cookiecutter.project_slug}}/CODEOWNERS.md b/tier2/{{cookiecutter.project_slug}}/CODEOWNERS.md index 5ef6967..eea9070 100644 --- a/tier2/{{cookiecutter.project_slug}}/CODEOWNERS.md +++ b/tier2/{{cookiecutter.project_slug}}/CODEOWNERS.md @@ -1,8 +1,32 @@ # Code Owners -{usernames of code owners} +{% set code_owners = cookiecutter.code_owners.split(',') %} +{% for item in code_owners %}- {{ item }} +{% endfor %} -# Repo Domains - -documentation/* {usernames of documentation owners} -frontend/* {usernames of frontend owners} +## Repo Domains + + + +/docs/ {Git usernames of documentation owners} +/frontend/ {Git usernames of frontend owners} diff --git a/tier2/{{cookiecutter.project_slug}}/MAINTAINERS.md b/tier2/{{cookiecutter.project_slug}}/MAINTAINERS.md index 0b9205c..45ba643 100644 --- a/tier2/{{cookiecutter.project_slug}}/MAINTAINERS.md +++ b/tier2/{{cookiecutter.project_slug}}/MAINTAINERS.md @@ -9,3 +9,9 @@ This is a list of maintainers for this project. See [CODEOWNERS.md](./CODEOWNERS |:-----|:-----|:-----|:-----| | {role} | {names} | {github usernames} | {affiliations}| +## Contributors + +Total number of contributors: + + + diff --git a/tier3/cookiecutter.json b/tier3/cookiecutter.json index d392afd..b159a65 100644 --- a/tier3/cookiecutter.json +++ b/tier3/cookiecutter.json @@ -4,6 +4,7 @@ "project_org": "DSACMS", "project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", "project_description": "This is the project description, could match github.com repo description.", + "code_owners": "Git usernames of code owners; separated by commas.", "project_visibility": ["public", "internal", "private"], "create_repo": [true, false], "receive_updates": [true, false], diff --git a/tier3/{{cookiecutter.project_slug}}/.github/workflows/checks.yml b/tier3/{{cookiecutter.project_slug}}/.github/workflows/checks.yml index f45cd8e..5b1b8e7 100644 --- a/tier3/{{cookiecutter.project_slug}}/.github/workflows/checks.yml +++ b/tier3/{{cookiecutter.project_slug}}/.github/workflows/checks.yml @@ -15,7 +15,9 @@ jobs: needs: resolve-repolinter-json runs-on: ubuntu-latest env: - RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json}} + {% raw %} + RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json }} + {% endraw %} steps: - uses: actions/checkout@v4 - run: echo $RAW_JSON > repolinter.json diff --git a/tier3/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml b/tier3/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml new file mode 100644 index 0000000..5e889b7 --- /dev/null +++ b/tier3/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml @@ -0,0 +1,62 @@ +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + update-contributors: + runs-on: ubuntu-latest + name: Update contributors info in MAINTAINERS.md + permissions: + contents: write + pull-requests: write + steps: + # Update contributor list + - name: Contribute List + uses: akhilmhdh/contributors-readme-action@v2.3.10 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # https://github.com/marketplace/actions/contribute-list#optional-parameters + readme_path: MAINTAINERS.md + use_username: false + commit_message: "BOT: Update contributors info in MAINTAINERS.md" + + # Update contributor count + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pull changes from contributors-readme-action + run: | + git pull + + - name: Get repository contributors count + id: get_contributors + # https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors + # https://docs.github.com/en/graphql/reference/objects#repositorycollaboratorconnection + # https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#communicating-with-graphql + # CANNOT have newlines! + run: | + OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) + REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) + QUERY='query { repository(owner: \"'"$OWNER"'\", name: \"'"$REPO"'\") { collaborators { totalCount } } }' + CONTRIBUTORS=$(curl -s -X POST -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "{\"query\": \"$QUERY\"}" https://api.github.com/graphql | jq -r '.data.repository.collaborators.totalCount') + echo "Total contributors: $CONTRIBUTORS" + echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT + + - name: Replace slug in MAINTAINERS.md with number of contributors + # https://stackoverflow.com/questions/10613643/replace-a-unknown-string-between-two-known-strings-with-sed + run: | + CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }} + sed -i 's/.*/ '"$CONTRIBUTORS"' /g' MAINTAINERS.md + + - name: Commit and push changes + # https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 + # commit changes, but if no changes exist, then exit cleanly + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git add MAINTAINERS.md + git commit -m "BOT: Update contributors info in MAINTAINERS.md" || exit 0 + git push diff --git a/tier3/{{cookiecutter.project_slug}}/CODEOWNERS.md b/tier3/{{cookiecutter.project_slug}}/CODEOWNERS.md index 5ef6967..eea9070 100644 --- a/tier3/{{cookiecutter.project_slug}}/CODEOWNERS.md +++ b/tier3/{{cookiecutter.project_slug}}/CODEOWNERS.md @@ -1,8 +1,32 @@ # Code Owners -{usernames of code owners} +{% set code_owners = cookiecutter.code_owners.split(',') %} +{% for item in code_owners %}- {{ item }} +{% endfor %} -# Repo Domains - -documentation/* {usernames of documentation owners} -frontend/* {usernames of frontend owners} +## Repo Domains + + + +/docs/ {Git usernames of documentation owners} +/frontend/ {Git usernames of frontend owners} diff --git a/tier3/{{cookiecutter.project_slug}}/MAINTAINERS.md b/tier3/{{cookiecutter.project_slug}}/MAINTAINERS.md index e0826cf..8f97204 100644 --- a/tier3/{{cookiecutter.project_slug}}/MAINTAINERS.md +++ b/tier3/{{cookiecutter.project_slug}}/MAINTAINERS.md @@ -17,4 +17,11 @@ This is a list of maintainers for this project. See [CODEOWNERS.md](./CODEOWNERS | member | active contributor in the community | multiple contributions to the project. | PROJECT GitHub org Committer Team| | reviewer | review contributions from other members | history of review and authorship in a subproject | MAINTAINERS file reviewer entry, and GitHub Org Triage Team| | approver | approve accepting contributions | highly experienced and active reviewer + contributor to a subproject | MAINTAINERS file approver entry and GitHub Triage Team | -| lead | set direction and priorities for a subproject | demonstrated responsibility and excellent technical judgement for the subproject | MAINTAINERS file owner entry and GitHub Org Admin Team| \ No newline at end of file +| lead | set direction and priorities for a subproject | demonstrated responsibility and excellent technical judgement for the subproject | MAINTAINERS file owner entry and GitHub Org Admin Team| + +## Contributors + +Total number of contributors: + + + diff --git a/tier4/cookiecutter.json b/tier4/cookiecutter.json index d392afd..b159a65 100644 --- a/tier4/cookiecutter.json +++ b/tier4/cookiecutter.json @@ -4,6 +4,7 @@ "project_org": "DSACMS", "project_repo_name": "{{ cookiecutter.project_name.lower().replace(' ', '-') }}", "project_description": "This is the project description, could match github.com repo description.", + "code_owners": "Git usernames of code owners; separated by commas.", "project_visibility": ["public", "internal", "private"], "create_repo": [true, false], "receive_updates": [true, false], diff --git a/tier4/{{cookiecutter.project_slug}}/.github/workflows/checks.yml b/tier4/{{cookiecutter.project_slug}}/.github/workflows/checks.yml index 77c3963..2af340c 100644 --- a/tier4/{{cookiecutter.project_slug}}/.github/workflows/checks.yml +++ b/tier4/{{cookiecutter.project_slug}}/.github/workflows/checks.yml @@ -15,7 +15,9 @@ jobs: needs: resolve-repolinter-json runs-on: ubuntu-latest env: - RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json}} + {% raw %} + RAW_JSON: ${{ needs.resolve-repolinter-json.outputs.raw-json }} + {% endraw %} steps: - uses: actions/checkout@v4 - run: echo $RAW_JSON > repolinter.json diff --git a/tier4/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml b/tier4/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml new file mode 100644 index 0000000..5e889b7 --- /dev/null +++ b/tier4/{{cookiecutter.project_slug}}/.github/workflows/contributors.yml @@ -0,0 +1,62 @@ +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + update-contributors: + runs-on: ubuntu-latest + name: Update contributors info in MAINTAINERS.md + permissions: + contents: write + pull-requests: write + steps: + # Update contributor list + - name: Contribute List + uses: akhilmhdh/contributors-readme-action@v2.3.10 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # https://github.com/marketplace/actions/contribute-list#optional-parameters + readme_path: MAINTAINERS.md + use_username: false + commit_message: "BOT: Update contributors info in MAINTAINERS.md" + + # Update contributor count + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Pull changes from contributors-readme-action + run: | + git pull + + - name: Get repository contributors count + id: get_contributors + # https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors + # https://docs.github.com/en/graphql/reference/objects#repositorycollaboratorconnection + # https://docs.github.com/en/graphql/guides/forming-calls-with-graphql#communicating-with-graphql + # CANNOT have newlines! + run: | + OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1) + REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2) + QUERY='query { repository(owner: \"'"$OWNER"'\", name: \"'"$REPO"'\") { collaborators { totalCount } } }' + CONTRIBUTORS=$(curl -s -X POST -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "{\"query\": \"$QUERY\"}" https://api.github.com/graphql | jq -r '.data.repository.collaborators.totalCount') + echo "Total contributors: $CONTRIBUTORS" + echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT + + - name: Replace slug in MAINTAINERS.md with number of contributors + # https://stackoverflow.com/questions/10613643/replace-a-unknown-string-between-two-known-strings-with-sed + run: | + CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }} + sed -i 's/.*/ '"$CONTRIBUTORS"' /g' MAINTAINERS.md + + - name: Commit and push changes + # https://github.com/orgs/community/discussions/26560#discussioncomment-3531273 + # commit changes, but if no changes exist, then exit cleanly + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + git add MAINTAINERS.md + git commit -m "BOT: Update contributors info in MAINTAINERS.md" || exit 0 + git push diff --git a/tier4/{{cookiecutter.project_slug}}/CODEOWNERS.md b/tier4/{{cookiecutter.project_slug}}/CODEOWNERS.md index 5ef6967..eea9070 100644 --- a/tier4/{{cookiecutter.project_slug}}/CODEOWNERS.md +++ b/tier4/{{cookiecutter.project_slug}}/CODEOWNERS.md @@ -1,8 +1,32 @@ # Code Owners -{usernames of code owners} +{% set code_owners = cookiecutter.code_owners.split(',') %} +{% for item in code_owners %}- {{ item }} +{% endfor %} -# Repo Domains - -documentation/* {usernames of documentation owners} -frontend/* {usernames of frontend owners} +## Repo Domains + + + +/docs/ {Git usernames of documentation owners} +/frontend/ {Git usernames of frontend owners} diff --git a/tier4/{{cookiecutter.project_slug}}/MAINTAINERS.md b/tier4/{{cookiecutter.project_slug}}/MAINTAINERS.md index 550f3a7..8f97204 100644 --- a/tier4/{{cookiecutter.project_slug}}/MAINTAINERS.md +++ b/tier4/{{cookiecutter.project_slug}}/MAINTAINERS.md @@ -2,14 +2,14 @@ This is a list of maintainers for this project. See [CODEOWNERS.md](./CODEOWNERS.md) for list of reviewers for different parts of the codebase. Team members include: -Maintainers: +## Maintainers: - -Approvers: +## Approvers: - -Reviewers: +## Reviewers: - | Roles | Responsibilities| Requirements | Defined by| @@ -18,3 +18,10 @@ Reviewers: | reviewer | review contributions from other members | history of review and authorship in a subproject | MAINTAINERS file reviewer entry, and GitHub Org Triage Team| | approver | approve accepting contributions | highly experienced and active reviewer + contributor to a subproject | MAINTAINERS file approver entry and GitHub Triage Team | | lead | set direction and priorities for a subproject | demonstrated responsibility and excellent technical judgement for the subproject | MAINTAINERS file owner entry and GitHub Org Admin Team| + +## Contributors + +Total number of contributors: + + +