Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnson alaric committed Sep 16, 2024
1 parent b7656b3 commit f7becac
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/copymd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Copy MD Files from All Repos

on:
push:
branches: [main]
workflow_dispatch:


jobs:
copy-md-files:
runs-on: ubuntu-latest
steps:
- name: Checkout current repository
uses: actions/checkout@v3

- name: Set up Git
run: |
git config --global user.name 'github-actions'
git config --global user.email 'actions@github.com'
- name: Fetch all repositories
run: |
# Get all repositories (change `my-username` to your GitHub username or organization)
repos=$(curl -s -H "Authorization: token ${{ secrets.REPO_ACCESS_TOKEN }}" \
https://api.github.com/user/repos?per_page=100 | jq -r '.[].full_name')
echo "$repos" > repos.txt
- name: Copy MD files from all repos
run: |
while IFS= read -r repo; do
echo "Processing repository: $repo"
# Create a directory for the repo
mkdir -p "repos/$(echo $repo | sed 's/\//_/g')"
# Clone the repo
git clone https://github.com/$repo.git temp-repo
cd temp-repo
# Find and copy .md files
find . -name "*.md" -exec bash -c '
for file; do
# Get the file hash
hash=$(git hash-object "$file")
# Copy the file to the main repo with a new name
cp "$file" "../../repos/$(echo $repo | sed 's/\//_/g')/${hash}.md"
done
' bash {} +
# Clean up
cd ..
rm -rf temp-repo
done < repos.txt
- name: Commit and push changes
run: |
git add repos/
git commit -m "Add .md files from all repositories"
git push

0 comments on commit f7becac

Please sign in to comment.