-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Johnson alaric
committed
Sep 16, 2024
1 parent
b7656b3
commit f7becac
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |