Skip to content

Commit

Permalink
Merge pull request #123 from DSACMS/add-tree-gh-action
Browse files Browse the repository at this point in the history
Add tree repo structure GH Action
  • Loading branch information
IsaacMilarky authored Jul 25, 2024
2 parents f4cfdbd + 6c6531c commit 748b746
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
push:
branches:
- main
workflow_dispatch:

jobs:
populate-repo-structure:
runs-on: ubuntu-latest
name: Update repo structure in README.md
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Populate repository structure with tree command
# https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed
# https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern
run: |
quoteSubst() {
IFS= read -d '' -r < <(sed -e ':a' -e '$!{N;ba' -e '}' -e 's/[&/\]/\\&/g; s/\n/\\&/g' <<<"$1")
printf %s "${REPLY%$'\n'}"
}
TREE_OUTPUT=$(tree -d)
sed -i 's/<!--TREE START--><!--TREE END-->/\n```plaintext\n'"$(quoteSubst $TREE_OUTPUT)"'\n```\n/g' README.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 README.md
git commit -m "BOT: Update repo structure in README.md" || exit 0
git push
1 change: 1 addition & 0 deletions tier3/{{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ An up-to-date list of core team members can be found in [MAINTAINERS.md](MAINTAI
## Repository Structure

<!-- TODO: Using the "tree -d" command can be a helpful way to generate this information, but, be sure to update it as the project evolves and changes over time.-->
<!--TREE START--><!--TREE END-->

**{list directories and descriptions}**

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
on:
push:
branches:
- main
workflow_dispatch:

jobs:
populate-repo-structure:
runs-on: ubuntu-latest
name: Update repo structure in README.md
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Populate repository structure with tree command
# https://stackoverflow.com/questions/29613304/is-it-possible-to-escape-regex-metacharacters-reliably-with-sed
# https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern
run: |
quoteSubst() {
IFS= read -d '' -r < <(sed -e ':a' -e '$!{N;ba' -e '}' -e 's/[&/\]/\\&/g; s/\n/\\&/g' <<<"$1")
printf %s "${REPLY%$'\n'}"
}
TREE_OUTPUT=$(tree -d)
sed -i 's/<!--TREE START--><!--TREE END-->/\n```plaintext\n'"$(quoteSubst $TREE_OUTPUT)"'\n```\n/g' README.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 README.md
git commit -m "BOT: Update repo structure in README.md" || exit 0
git push
1 change: 1 addition & 0 deletions tier4/{{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ An up-to-date list of core team members can be found in [MAINTAINERS.md](MAINTAI
## Repository Structure

<!-- TODO: Using the "tree -d" command can be a helpful way to generate this information, but, be sure to update it as the project evolves and changes over time. -->
<!--TREE START--><!--TREE END-->

**{list directories and descriptions}**

Expand Down

0 comments on commit 748b746

Please sign in to comment.